From 18f9cad6fef1fb71dc976a4fb2e1775f18a1ccaa Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 23 Apr 2023 23:26:00 -0700 Subject: [PATCH] Adding "indent.sh" to re-indent code; ran it!!! --- docs/CHANGES.txt | 6 + magic/src/WIP/rivulet.c | 205 +- magic/src/alien.c | 80 +- magic/src/blind.c | 91 +- magic/src/blocks_etc.c | 136 +- magic/src/bloom.c | 186 +- magic/src/blur.c | 71 +- magic/src/bricks.c | 105 +- magic/src/calligraphy.c | 100 +- magic/src/cartoon.c | 111 +- magic/src/checkerboard.c | 92 +- magic/src/clone.c | 85 +- magic/src/colorsep.c | 154 +- magic/src/confetti.c | 82 +- magic/src/distortion.c | 83 +- magic/src/emboss.c | 73 +- magic/src/fade_darken.c | 139 +- magic/src/fisheye.c | 109 +- magic/src/flower.c | 171 +- magic/src/foam.c | 104 +- magic/src/fold.c | 230 +- magic/src/fretwork.c | 200 +- magic/src/glasstile.c | 98 +- magic/src/googlyeyes.c | 189 +- magic/src/grass.c | 105 +- magic/src/halftone.c | 93 +- magic/src/kaleidox.c | 156 +- magic/src/kalidescope.c | 91 +- magic/src/light.c | 75 +- magic/src/lightning.c | 107 +- magic/src/maze.c | 304 +- magic/src/metalpaint.c | 81 +- magic/src/mirror_flip.c | 66 +- magic/src/mosaic.c | 127 +- magic/src/mosaic_shaped.c | 368 +-- magic/src/negative.c | 90 +- magic/src/noise.c | 86 +- magic/src/perspective.c | 275 +- magic/src/pixels.c | 63 +- magic/src/puzzle.c | 93 +- magic/src/rails.c | 146 +- magic/src/rain.c | 75 +- magic/src/rainbow.c | 77 +- magic/src/realrainbow.c | 115 +- magic/src/reflection.c | 92 +- magic/src/ripples.c | 87 +- magic/src/rosette.c | 104 +- magic/src/sharpen.c | 97 +- magic/src/shift.c | 69 +- magic/src/smudge.c | 92 +- magic/src/snow.c | 67 +- magic/src/stretch.c | 79 +- magic/src/string.c | 228 +- magic/src/swirls.c | 231 +- magic/src/tint.c | 92 +- magic/src/toothpaste.c | 85 +- magic/src/tornado.c | 144 +- magic/src/tv.c | 73 +- magic/src/waves.c | 58 +- magic/src/xor.c | 72 +- src/android_assets.c | 31 +- src/android_assets.h | 23 +- src/android_mbstowcs.c | 4 +- src/android_print.c | 61 +- src/cursor.c | 3 +- src/cursor.h | 3 +- src/dirwalk.c | 96 +- src/dirwalk.h | 6 +- src/fill.c | 352 +-- src/fill.h | 15 +- src/fill_tools.h | 9 +- src/fonts.c | 190 +- src/fonts.h | 15 +- src/get_fname.c | 1 + src/gifenc.c | 14 +- src/gifenc.h | 3 +- src/i18n.c | 75 +- src/i18n.h | 5 +- src/im.c | 97 +- src/indent.sh | 16 + src/onscreen_keyboard.c | 203 +- src/onscreen_keyboard.h | 7 +- src/pixels.c | 32 +- src/playsound.c | 6 +- src/playsound.h | 3 +- src/postscript_print.c | 35 +- src/postscript_print.h | 3 +- src/progressbar.c | 7 +- src/progressbar.h | 3 +- src/rgblinear.h | 3 +- src/shapes.h | 17 +- src/test-png.c | 10 +- src/tuxpaint.c | 6195 ++++++++++++++----------------------- src/win32_dirent.c | 22 +- src/win32_dirent.h | 3 +- src/win32_print.c | 62 +- src/win32_print.h | 3 +- src/win32_trash.c | 3 +- 98 files changed, 5798 insertions(+), 9001 deletions(-) create mode 100755 src/indent.sh diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 7b32535c7..db7f35d07 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -106,6 +106,12 @@ https://tuxpaint.org/ * Don't try to load a blank-named template during slideshow playback. Bill Kendrick + * Ports & Building: + ----------------- + * Created "src/indent.sh", to run 'indent' against source files. + Ran it during 0.9.30 development. + Bill Kendrick + * Localization Updates: --------------------- * Chinese (Simplified) translation diff --git a/magic/src/WIP/rivulet.c b/magic/src/WIP/rivulet.c index 2b71051ef..d82e10f6d 100644 --- a/magic/src/WIP/rivulet.c +++ b/magic/src/WIP/rivulet.c @@ -26,15 +26,11 @@ // #define DEBUG_ANGLE Mix_Chunk *snd_effect = NULL; -SDL_Surface * rivulet_img_brush_add = NULL, - * rivulet_img_brush_alpha = NULL, - * rivulet_img_brush_sub = NULL, - * rivulet_img_angles = NULL; -SDL_Surface * rivulet_snapshot = NULL; +SDL_Surface *rivulet_img_brush_add = NULL, + *rivulet_img_brush_alpha = NULL, *rivulet_img_brush_sub = NULL, *rivulet_img_angles = NULL; +SDL_Surface *rivulet_snapshot = NULL; int riv_x, riv_y; -Uint8 * riv_radii = NULL, - * riv_alpha = NULL, - * riv_angles = NULL; +Uint8 *riv_radii = NULL, *riv_alpha = NULL, *riv_angles = NULL; Uint32 rivulet_api_version(void); int rivulet_init(magic_api * api); @@ -47,22 +43,16 @@ int rivulet_requires_colors(magic_api * api, int which); int rivulet_modes(magic_api * api, int which); void rivulet_shutdown(magic_api * api); void rivulet_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 rivulet_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void rivulet_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 rivulet_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void rivulet_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void rivulet_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -void rivulet_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void rivulet_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +void rivulet_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void rivulet_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void zero_riv_arrays(SDL_Surface * canvas); @@ -82,8 +72,7 @@ int rivulet_init(magic_api * api) /* Load our images */ - snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-add.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-add.png", api->data_directory); rivulet_img_brush_add = IMG_Load(fname); if (rivulet_img_brush_add == NULL) { @@ -91,8 +80,7 @@ int rivulet_init(magic_api * api) return 0; } - snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-alpha.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-alpha.png", api->data_directory); rivulet_img_brush_alpha = IMG_Load(fname); if (rivulet_img_brush_alpha == NULL) { @@ -100,8 +88,7 @@ int rivulet_init(magic_api * api) return 0; } - snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-sub.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-sub.png", api->data_directory); rivulet_img_brush_sub = IMG_Load(fname); if (rivulet_img_brush_sub == NULL) { @@ -109,8 +96,7 @@ int rivulet_init(magic_api * api) return 0; } - snprintf(fname, sizeof(fname), "%simages/magic/rivulet-angles.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rivulet-angles.png", api->data_directory); rivulet_img_angles = IMG_Load(fname); if (rivulet_img_angles == NULL) { @@ -131,39 +117,32 @@ SDL_Surface *rivulet_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/rivulet.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rivulet.png", api->data_directory); return (IMG_Load(fname)); } -char *rivulet_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *rivulet_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext("Rivulet")); } -int rivulet_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rivulet_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } -char *rivulet_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *rivulet_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return(gettext("Click and drag downward to add water rivulets to your drawing")); + return (gettext("Click and drag downward to add water rivulets to your drawing")); } -int rivulet_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rivulet_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -int rivulet_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rivulet_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT; } @@ -198,8 +177,7 @@ void rivulet_shutdown(magic_api * api ATTRIBUTE_UNUSED) void rivulet_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) { riv_x = x; riv_y = y - 1; @@ -208,10 +186,10 @@ rivulet_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, return; if (snd_effect != NULL) - { - api->stopsound(); - api->playsound(snd_effect, (x * 255) / canvas->w, 255); - } + { + api->stopsound(); + api->playsound(snd_effect, (x * 255) / canvas->w, 255); + } rivulet_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); } @@ -219,8 +197,8 @@ rivulet_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) + SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int old_riv_x, old_riv_y; @@ -243,8 +221,7 @@ rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, riv_x = x; riv_y = y; - api->line((void *) api, which, canvas, snapshot, old_riv_x, old_riv_y, riv_x, riv_y, 1, - rivulet_line_callback_drag); + api->line((void *)api, which, canvas, snapshot, old_riv_x, old_riv_y, riv_x, riv_y, 1, rivulet_line_callback_drag); /* FIXME */ update_rect->x = 0; @@ -254,11 +231,8 @@ rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, } -void -rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, - int x, int y, /* ignored and reused in a for-loop */ - SDL_Rect * update_rect) +void rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y, /* ignored and reused in a for-loop */ + SDL_Rect * update_rect) { int src_x, src_y, idx; double radius, angle_deg, angle_rad; @@ -294,12 +268,13 @@ rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED, api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, v, 64, 64)); #else - radius = ((double) riv_radii[idx]); + radius = ((double)riv_radii[idx]); alpha = riv_alpha[idx] / 2; - if (radius != 0.0) { + if (radius != 0.0) + { /* Angle is stored as 0-255 (so 256 would be 360 degrees) */ - angle_deg = ((((double) riv_angles[idx]) / 256.0) * 360.0); + angle_deg = ((((double)riv_angles[idx]) / 256.0) * 360.0); angle_rad = (angle_deg * M_PI) / 180.0; @@ -343,11 +318,9 @@ void rivulet_set_color(magic_api * api, int which, SDL_Surface * canvas, void rivulet_line_callback_drag(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 *api; SDL_Rect dest; int w, h, half_w, half_h, idx; int src_x, src_y, dest_x, dest_y; @@ -374,19 +347,23 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, /* Adjust the displacement maps */ - for (src_y = 0; src_y <= h; src_y++) { + for (src_y = 0; src_y <= h; src_y++) + { dest_y = (y - half_h) + src_y; - if (dest_y >= 0 && dest_y < canvas->h) { - for (src_x = 0; src_x < w; src_x++) { + if (dest_y >= 0 && dest_y < canvas->h) + { + for (src_x = 0; src_x < w; src_x++) + { dest_x = (x - half_w) + src_x; - if (dest_x >= 0 && dest_x < canvas->w) { + if (dest_x >= 0 && dest_x < canvas->w) + { idx = (dest_y * canvas->w) + dest_x; /* Add alpha */ pix = api->getpixel(rivulet_img_brush_alpha, src_x, src_y); SDL_GetRGB(pix, rivulet_img_brush_alpha->format, &intensity, &tmp, &tmp); - alpha = ((int) riv_alpha[idx] + (int) (intensity)); + alpha = ((int)riv_alpha[idx] + (int)(intensity)); if (alpha > 255) alpha = 255; riv_alpha[idx] = (Uint8) alpha; @@ -394,17 +371,17 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, /* Apply radius brush to radius displacement map */ if (alpha > 0) - { - pix = api->getpixel(rivulet_img_brush_add, src_x, src_y); - SDL_GetRGB(pix, rivulet_img_brush_add->format, &intensity, &tmp, &tmp); + { + pix = api->getpixel(rivulet_img_brush_add, src_x, src_y); + SDL_GetRGB(pix, rivulet_img_brush_add->format, &intensity, &tmp, &tmp); - radius = ((int) riv_radii[idx] + (int) intensity - 128); - if (radius < 0) - radius = 0; - if (radius > 255) - radius = 255; - riv_radii[idx] = radius; - } + radius = ((int)riv_radii[idx] + (int)intensity - 128); + if (radius < 0) + radius = 0; + if (radius > 255) + radius = 255; + riv_radii[idx] = radius; + } /* Apply angle brush to angle displacement map */ @@ -419,58 +396,54 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, } void rivulet_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { if (riv_radii == NULL) + { + riv_radii = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (riv_radii == NULL) { - riv_radii = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (riv_radii == NULL) - { - fprintf(stderr, "rivulet: Cannot malloc() riv_radii!\n"); - return; - } - - riv_alpha = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (riv_alpha == NULL) - { - free(riv_radii); - riv_radii = NULL; - - fprintf(stderr, "rivulet: Cannot malloc() riv_alpha!\n"); - return; - } - - riv_angles = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (riv_angles == NULL) - { - free(riv_radii); - riv_radii = NULL; - - free(riv_alpha); - riv_alpha = NULL; - - fprintf(stderr, "rivulet: Cannot malloc() riv_angles!\n"); - return; - } + fprintf(stderr, "rivulet: Cannot malloc() riv_radii!\n"); + return; } + riv_alpha = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (riv_alpha == NULL) + { + free(riv_radii); + riv_radii = NULL; + + fprintf(stderr, "rivulet: Cannot malloc() riv_alpha!\n"); + return; + } + + riv_angles = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (riv_angles == NULL) + { + free(riv_radii); + riv_radii = NULL; + + free(riv_alpha); + riv_alpha = NULL; + + fprintf(stderr, "rivulet: Cannot malloc() riv_angles!\n"); + return; + } + } + zero_riv_arrays(canvas); if (rivulet_snapshot == NULL) rivulet_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, - canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->BitsPerPixel, canvas->format->Rmask, + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); if (rivulet_snapshot != NULL) SDL_BlitSurface(canvas, NULL, rivulet_snapshot, NULL); } void rivulet_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) { zero_riv_arrays(canvas); } diff --git a/magic/src/alien.c b/magic/src/alien.c index bfbcfbf69..dd3925a67 100644 --- a/magic/src/alien.c +++ b/magic/src/alien.c @@ -72,8 +72,7 @@ const int alien_groups[alien_NUM_TOOLS] = { }; const char *alien_descs[alien_NUM_TOOLS][2] = { - {gettext_noop - ("Click and drag the mouse to change the colors in parts of your picture."), + {gettext_noop("Click and drag the mouse to change the colors in parts of your picture."), gettext_noop("Click to change the colors in your entire picture."),}, }; @@ -86,12 +85,10 @@ char *alien_get_name(magic_api * api, int which); int alien_get_group(magic_api * api, int which); char *alien_get_description(magic_api * api, int which, int mode); void alien_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); Mix_Chunk *magic_loadsound(char *file); void alien_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 alien_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void alien_shutdown(magic_api * api); @@ -101,12 +98,9 @@ int alien_requires_colors(magic_api * api, int which); Uint8 alien_accepted_sizes(magic_api * api, int which, int mode); Uint8 alien_default_size(magic_api * api, int which, int mode); void alien_set_size(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last, - Uint8 size, SDL_Rect * update_rect); -void alien_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void alien_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void alien_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void alien_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int alien_modes(magic_api * api, int which); @@ -125,8 +119,7 @@ int alien_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < alien_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - alien_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, alien_snd_filenames[i]); alien_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -142,8 +135,7 @@ SDL_Surface *alien_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - alien_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, alien_icon_filenames[which]); return (IMG_Load(fname)); } @@ -159,16 +151,14 @@ int alien_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *alien_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *alien_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(alien_descs[which][mode - 1]))); } //Do the effect for one pixel static void do_alien_pixel(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -176,25 +166,21 @@ static void do_alien_pixel(void *ptr, int which ATTRIBUTE_UNUSED, double temp2[3]; int k; - SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], - &temp[2]); + SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]); for (k = 0; k < 3; k++) { //EP temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255); temp2[k] = clamp(0.0, 127.5 * (1.0 + sin(((temp[k] / 127.5 - - 1.0) * alien_FREQUENCY[k] + - alien_ANGLE[k] / 180.0) * M_PI)), 255.0); + 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)), 255.0); } - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); } // Do the effect for the full image -static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which) +static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which) { int x, y; @@ -208,8 +194,7 @@ static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, } //do the effect for the brush -static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; magic_api *api = (magic_api *) ptr; @@ -218,8 +203,7 @@ static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas, { for (xx = x - alien_RADIUS; xx < x + alien_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, alien_RADIUS) - && !api->touched(xx, yy)) + if (api->in_circle(xx - x, yy - y, alien_RADIUS) && !api->touched(xx, yy)) { do_alien_pixel(api, which, canvas, last, xx, yy); } @@ -229,12 +213,10 @@ static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void alien_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_alien_brush); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_alien_brush); api->playsound(alien_snd_effect[which], (x * 255) / canvas->w, 255); @@ -275,8 +257,7 @@ Mix_Chunk *magic_loadsound(char *file) // Affect the canvas on click: void alien_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) alien_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -296,8 +277,7 @@ void alien_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -317,14 +297,15 @@ void alien_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void alien_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) +void alien_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) { } // Use colors: -int alien_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int alien_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -340,20 +321,19 @@ Uint8 alien_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U } void alien_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) { + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, + Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED) +{ alien_RADIUS = size * 4; } void alien_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 alien_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) { } diff --git a/magic/src/blind.c b/magic/src/blind.c index 8467f4f7b..451cb3c2c 100644 --- a/magic/src/blind.c +++ b/magic/src/blind.c @@ -65,24 +65,20 @@ int blind_get_group(magic_api * api, int which); char *blind_get_description(magic_api * api, int which, int mode); int blind_requires_colors(magic_api * api, int which); void blind_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 blind_shutdown(magic_api * api); -void blind_paint_blind(void *ptr_to_api, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +void blind_paint_blind(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void blind_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 blind_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); -void blind_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void blind_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void blind_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void blind_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int blind_modes(magic_api * api, int which); Uint8 blind_accepted_sizes(magic_api * api, int which, int mode); Uint8 blind_default_size(magic_api * api, int which, int mode); -void blind_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void blind_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // Housekeeping functions @@ -91,8 +87,9 @@ Uint32 blind_api_version(void) return (TP_MAGIC_API_VERSION); } -void blind_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 blind_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 blind_r = r; @@ -104,8 +101,7 @@ int blind_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/blind.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/blind.ogg", api->data_directory); blind_snd = Mix_LoadWAV(fname); return (1); @@ -120,35 +116,29 @@ SDL_Surface *blind_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/blind.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/blind.png", api->data_directory); return (IMG_Load(fname)); } -char *blind_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *blind_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Blind")); } -int blind_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int blind_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_DECORATIONS; } -char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return strdup(gettext_noop ("Click towards the edge of your picture to pull window blinds over it. Move perpendicularly to open or close the blinds.")); } -int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -157,8 +147,7 @@ void blind_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) { } @@ -170,15 +159,13 @@ void blind_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Interactivity functions void blind_paint_blind(void *ptr_to_api, int which_tool 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_to_api; api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, (blind_r + blind_light) / 2, - (blind_g + blind_light) / 2, - (blind_b + blind_light) / 2)); + (blind_g + blind_light) / 2, (blind_b + blind_light) / 2)); } /* void blind_do_blind(void * ptr_to_api, int which_tool, @@ -192,8 +179,7 @@ void blind_paint_blind(void *ptr_to_api, int which_tool ATTRIBUTE_UNUSED, */ void blind_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) { int opaque; @@ -209,14 +195,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas, blind_light = 255; for (j = i; j > i - opaque / 2; j--) { - api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind); blind_light -= 20; } for (j = i - opaque / 2; j > i - opaque; j--) { - api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind); blind_light += 20; } } @@ -234,14 +218,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas, blind_light = 255; for (j = i; j < i + opaque / 2; j++) { - api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind); blind_light -= 20; } for (j = i + opaque / 2; j < i + opaque; j++) { - api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind); blind_light += 20; } } @@ -260,14 +242,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas, blind_light = 255; for (j = i; j < i + opaque / 2; j++) { - api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind); blind_light -= 20; } for (j = i + opaque / 2; j < i + opaque; j++) { - api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind); blind_light += 20; } } @@ -286,14 +266,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas, blind_light = 255; for (j = i; j > i - opaque / 2; j--) { - api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind); blind_light -= 20; } for (j = i - opaque / 2; j > i - opaque; j--) { - api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, - blind_paint_blind); + api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind); blind_light += 20; } } @@ -308,8 +286,7 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas, } void blind_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) { if (y < canvas->h / 2) @@ -335,15 +312,13 @@ void blind_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, } void blind_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 blind_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) { } @@ -363,6 +338,8 @@ Uint8 blind_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 0; } -void blind_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 blind_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) { } diff --git a/magic/src/blocks_etc.c b/magic/src/blocks_etc.c index 426cecdd6..59d1209f3 100644 --- a/magic/src/blocks_etc.c +++ b/magic/src/blocks_etc.c @@ -59,30 +59,24 @@ SDL_Surface *blocks_etc_get_icon(magic_api * api, int which); char *blocks_etc_get_name(magic_api * api, int which); int blocks_etc_get_group(magic_api * api, int which); char *blocks_etc_get_description(magic_api * api, int which, int mode); -static void blocks_etc_linecb(void *ptr, int which, - SDL_Surface * canvas, SDL_Surface * last, - int x, int y); +static void blocks_etc_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void blocks_etc_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); void blocks_etc_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 blocks_etc_release(magic_api * api, int which, - 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 blocks_etc_shutdown(magic_api * api); void blocks_etc_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); int blocks_etc_requires_colors(magic_api * api, int which); -void blocks_etc_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void blocks_etc_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void blocks_etc_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void blocks_etc_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int blocks_etc_modes(magic_api * api, int which); Uint8 blocks_etc_accepted_sizes(magic_api * api, int which, int mode); Uint8 blocks_etc_default_size(magic_api * api, int which, int mode); -void blocks_etc_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void blocks_etc_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -90,16 +84,13 @@ int blocks_etc_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/blocks.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/blocks.wav", api->data_directory); snd_effect[0] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/chalk.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/chalk.wav", api->data_directory); snd_effect[1] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/drip.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/drip.wav", api->data_directory); snd_effect[2] = Mix_LoadWAV(fname); return (1); @@ -124,18 +115,15 @@ SDL_Surface *blocks_etc_get_icon(magic_api * api, int which) if (which == TOOL_BLOCKS) { - snprintf(fname, sizeof(fname), "%simages/magic/blocks.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/blocks.png", api->data_directory); } else if (which == TOOL_CHALK) { - snprintf(fname, sizeof(fname), "%simages/magic/chalk.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/chalk.png", api->data_directory); } else if (which == TOOL_DRIP) { - snprintf(fname, sizeof(fname), "%simages/magic/drip.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/drip.png", api->data_directory); } return (IMG_Load(fname)); @@ -155,52 +143,41 @@ char *blocks_etc_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (all the same): -int blocks_etc_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int blocks_etc_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which, int mode) +char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { if (which == TOOL_BLOCKS) { if (mode == MODE_PAINT) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to make the picture blocky."))); + return (strdup(gettext_noop("Click and drag the mouse around to make the picture blocky."))); } else { - return (strdup - (gettext_noop("Click to make the entire picture blocky."))); + return (strdup(gettext_noop("Click to make the entire picture blocky."))); } } else if (which == TOOL_CHALK) { if (mode == MODE_PAINT) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to turn the picture into a chalk drawing."))); + return (strdup(gettext_noop("Click and drag the mouse around to turn the picture into a chalk drawing."))); } else { - return (strdup - (gettext_noop - ("Click to turn the entire picture into a chalk drawing."))); + return (strdup(gettext_noop("Click to turn the entire picture into a chalk drawing."))); } } else if (which == TOOL_DRIP) { if (mode == MODE_PAINT) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to make the picture drip."))); + return (strdup(gettext_noop("Click and drag the mouse around to make the picture drip."))); } else { @@ -213,9 +190,7 @@ char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect: -static void blocks_etc_linecb(void *ptr, int which, - SDL_Surface * canvas, SDL_Surface * last, - int x, int y) +static void blocks_etc_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -233,11 +208,9 @@ static void blocks_etc_linecb(void *ptr, int which, if (!api->touched(x, y)) { - for (yy = y - (EFFECT_REZ * 2); yy < y + (EFFECT_REZ * 2); - yy = yy + EFFECT_REZ) + for (yy = y - (EFFECT_REZ * 2); yy < y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ) { - for (xx = x - (EFFECT_REZ * 2); xx < x + (EFFECT_REZ * 2); - xx = xx + EFFECT_REZ) + for (xx = x - (EFFECT_REZ * 2); xx < x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ) { Uint32 pix[(EFFECT_REZ * EFFECT_REZ)]; Uint32 p_or = 0; @@ -271,12 +244,9 @@ static void blocks_etc_linecb(void *ptr, int which, g_sum += api->sRGB_to_linear(g); b_sum += api->sRGB_to_linear(b); } - r = - api->linear_to_sRGB(r_sum / (float) (EFFECT_REZ * EFFECT_REZ)); - g = - api->linear_to_sRGB(g_sum / (float) (EFFECT_REZ * EFFECT_REZ)); - b = - api->linear_to_sRGB(b_sum / (float) (EFFECT_REZ * EFFECT_REZ)); + r = api->linear_to_sRGB(r_sum / (float)(EFFECT_REZ * EFFECT_REZ)); + g = api->linear_to_sRGB(g_sum / (float)(EFFECT_REZ * EFFECT_REZ)); + b = api->linear_to_sRGB(b_sum / (float)(EFFECT_REZ * EFFECT_REZ)); } /* Draw block: */ @@ -293,20 +263,16 @@ static void blocks_etc_linecb(void *ptr, int which, } else if (which == TOOL_CHALK) { - for (yy = y - (EFFECT_REZ * 2); yy <= y + (EFFECT_REZ * 2); - yy = yy + EFFECT_REZ) + for (yy = y - (EFFECT_REZ * 2); yy <= y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ) { - for (xx = x - (EFFECT_REZ * 2); xx <= x + (EFFECT_REZ * 2); - xx = xx + EFFECT_REZ) + for (xx = x - (EFFECT_REZ * 2); xx <= x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ) { dest.x = xx + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2)); dest.y = yy + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2)); dest.w = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2); dest.h = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2); - colr = - api->getpixel(last, clamp(0, xx, canvas->w - 1), - clamp(0, yy, canvas->h - 1)); + colr = api->getpixel(last, clamp(0, xx, canvas->w - 1), clamp(0, yy, canvas->h - 1)); SDL_FillRect(canvas, &dest, colr); } } @@ -335,11 +301,9 @@ static void blocks_etc_linecb(void *ptr, int which, // Affect the canvas on drag: void blocks_etc_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, - blocks_etc_linecb); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, blocks_etc_linecb); if (ox > x) { @@ -366,8 +330,7 @@ void blocks_etc_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void blocks_etc_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) { @@ -393,6 +356,7 @@ void blocks_etc_click(magic_api * api, int which, int mode, { /* Drip (works from bottom-to-top) */ int p = (canvas->h - 1) % 10; + for (y = canvas->h - 1; y >= 0; y -= EFFECT_REZ) { if ((y + p) % 10 == 0) @@ -416,11 +380,10 @@ void blocks_etc_click(magic_api * api, int which, int mode, // Affect the canvas on release: void blocks_etc_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) + 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) { } @@ -435,29 +398,26 @@ void blocks_etc_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void blocks_etc_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) +void blocks_etc_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) { } // Use colors: -int blocks_etc_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int blocks_etc_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void blocks_etc_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 blocks_etc_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) { } @@ -480,7 +440,9 @@ Uint8 blocks_etc_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB return 2; } -void blocks_etc_set_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED) +void blocks_etc_set_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED, + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { if (which == TOOL_BLOCKS) EFFECT_REZ = size * 4; diff --git a/magic/src/bloom.c b/magic/src/bloom.c index 541a6bf27..3c655427e 100644 --- a/magic/src/bloom.c +++ b/magic/src/bloom.c @@ -37,8 +37,8 @@ float sample_weights[NUM_SAMPLE_WEIGHTS] = { 0.0449, 0.0627, 0.0752, 0.0842, 0.0904, 0.0940, 0.0952, 0.0940, 0.0904, 0.0842, 0.0752, 0.0627, 0.0449 }; -Mix_Chunk * snd_effects = NULL; -Uint8 * bloom_mask = NULL; +Mix_Chunk *snd_effects = NULL; +Uint8 *bloom_mask = NULL; int bloom_scale; Uint32 bloom_api_version(void); @@ -52,30 +52,23 @@ int bloom_requires_colors(magic_api * api, int which); int bloom_modes(magic_api * api, int which); void bloom_shutdown(magic_api * api); void bloom_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 bloom_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 bloom_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 bloom_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void bloom_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void bloom_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -void bloom_apply_effect(magic_api * api, - SDL_Surface * canvas, - SDL_Surface * snapshot); -void bloom_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void bloom_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +void bloom_apply_effect(magic_api * api, SDL_Surface * canvas, SDL_Surface * snapshot); +void bloom_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void bloom_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); float luminance(float r, float g, float b); float change_luminance(float c_in, float l_in, float l_out); Uint8 bloom_accepted_sizes(magic_api * api, int which, int mode); Uint8 bloom_default_size(magic_api * api, int which, int mode); -void bloom_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void bloom_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 bloom_api_version(void) @@ -87,8 +80,7 @@ int bloom_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/bloom.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/bloom.ogg", api->data_directory); snd_effects = Mix_LoadWAV(fname); bloom_scale = sqrt(2 * (BLOOM_PAINT_RADIUS * BLOOM_PAINT_RADIUS)); @@ -105,54 +97,53 @@ SDL_Surface *bloom_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/bloom.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/bloom.png", api->data_directory); return (IMG_Load(fname)); } -char *bloom_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *bloom_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext("Bloom")); } -int bloom_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED) +int bloom_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED) { return MAGIC_TYPE_COLOR_FILTERS; } -char *bloom_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *bloom_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { - if (mode == MODE_PAINT) { + if (mode == MODE_PAINT) + { return strdup(gettext("Click and drag to apply a glowing \"bloom\" effect to parts of your image.")); - } else { + } + else + { return strdup(gettext("Click to apply a glowing \"bloom\" effect to your entire image.")); } } -int bloom_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int bloom_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { - return 0; /* TODO: Maybe some day? */ + return 0; /* TODO: Maybe some day? */ } -int bloom_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED) +int bloom_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } void bloom_shutdown(magic_api * api ATTRIBUTE_UNUSED) { - if (snd_effects != NULL) { + if (snd_effects != NULL) + { Mix_FreeChunk(snd_effects); snd_effects = NULL; } - if (bloom_mask != NULL) { + if (bloom_mask != NULL) + { free(bloom_mask); bloom_mask = NULL; } @@ -160,8 +151,7 @@ void bloom_shutdown(magic_api * api ATTRIBUTE_UNUSED) void bloom_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) { if (bloom_mask == NULL) return; @@ -169,11 +159,15 @@ bloom_click(magic_api * api, int which, int mode, if (snd_effects != NULL) api->stopsound(); - if (mode == MODE_PAINT) { + if (mode == MODE_PAINT) + { memset(bloom_mask, 0, (canvas->w * canvas->h)); bloom_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); - } else { - if (snd_effects != NULL) { + } + else + { + if (snd_effects != NULL) + { api->playsound(snd_effects, (x * 255) / canvas->w, 255); } @@ -190,12 +184,12 @@ bloom_click(magic_api * api, int which, int mode, void bloom_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, 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) { if (bloom_mask == NULL) return; - api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */, + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */ , bloom_line_callback_drag); /* FIXME: Would be good to only update the area around the line (ox,oy)->(x,y) (+/- the maxium radius of the effect) */ @@ -207,10 +201,9 @@ bloom_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Sur void bloom_release(magic_api * api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * snapshot, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect) { + SDL_Surface * canvas, + SDL_Surface * snapshot, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) +{ if (bloom_mask == NULL) return; @@ -225,9 +218,8 @@ void bloom_release(magic_api * api, int which ATTRIBUTE_UNUSED, update_rect->h = canvas->h; } -void bloom_apply_effect(magic_api * api, - SDL_Surface * canvas, - SDL_Surface * snapshot) { +void bloom_apply_effect(magic_api * api, SDL_Surface * canvas, SDL_Surface * snapshot) +{ int sample, offset, offset_flip, x, y, xx, yy; Uint8 r, g, b; float rf, gf, bf, mask_weight, lum; @@ -236,19 +228,24 @@ void bloom_apply_effect(magic_api * api, SDL_BlitSurface(snapshot, NULL, canvas, NULL); - for (y = 0; y < canvas->h; y++) { - if (y % 10 == 0) { + for (y = 0; y < canvas->h; y++) + { + if (y % 10 == 0) + { api->update_progress_bar(); } - for (x = 0; x < canvas->w; x++) { - if (bloom_mask[y * canvas->w + x] > 0) { + for (x = 0; x < canvas->w; x++) + { + if (bloom_mask[y * canvas->w + x] > 0) + { sums[0] = 0.0; sums[1] = 0.0; sums[2] = 0.0; /* (Pull from snapshot) */ - for (sample = 0; sample < NUM_SAMPLE_WEIGHTS; sample++) { + for (sample = 0; sample < NUM_SAMPLE_WEIGHTS; sample++) + { /* Horizontal samples */ color = api->getpixel(snapshot, x - ((NUM_SAMPLE_WEIGHTS - 1) / 2) + sample, y); SDL_GetRGB(color, snapshot->format, &r, &g, &b); @@ -265,29 +262,34 @@ void bloom_apply_effect(magic_api * api, } /* (Blend an "X" shape, additively, onto target canvas) */ - for (offset = -BLOOM_SPIKE_LENGTH; offset <= BLOOM_SPIKE_LENGTH; offset++) { - for (offset_flip = -1; offset <= 1; offset += 2) { + for (offset = -BLOOM_SPIKE_LENGTH; offset <= BLOOM_SPIKE_LENGTH; offset++) + { + for (offset_flip = -1; offset <= 1; offset += 2) + { xx = x + offset; yy = y + (offset * offset_flip); - if (xx >= 0 && xx < canvas->w && yy >= 0 && yy < canvas->h) { + if (xx >= 0 && xx < canvas->w && yy >= 0 && yy < canvas->h) + { color = api->getpixel(snapshot, xx, yy); SDL_GetRGB(color, snapshot->format, &r, &g, &b); - mask_weight = (float) (bloom_mask[(yy) * canvas->w + xx] / 255.0); + mask_weight = (float)(bloom_mask[(yy) * canvas->w + xx] / 255.0); mask_weight *= BLOOM_WEIGHT_CONST; mask_weight *= ((BLOOM_SPIKE_LENGTH + 1) - (abs(offset)) / BLOOM_SPIKE_LENGTH); - rf = (((float) r) + (sums[0] * mask_weight)) / 255.0; - gf = (((float) g) + (sums[1] * mask_weight)) / 255.0; - bf = (((float) b) + (sums[2] * mask_weight)) / 255.0; + rf = (((float)r) + (sums[0] * mask_weight)) / 255.0; + gf = (((float)g) + (sums[1] * mask_weight)) / 255.0; + bf = (((float)b) + (sums[2] * mask_weight)) / 255.0; /* Reinhard Tonemap (Luminence) */ lum = luminance(rf, gf, bf); - if (lum > 0.0) { + if (lum > 0.0) + { float numerator = lum * (1.0f + lum); float l_new = numerator / (1.0f + lum); + rf = change_luminance(rf, lum, l_new); gf = change_luminance(gf, lum, l_new); bf = change_luminance(bf, lum, l_new); @@ -316,19 +318,17 @@ void bloom_apply_effect(magic_api * api, void bloom_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED 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) { /* TODO: Maybe some day? */ } void bloom_line_callback_drag(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) { int xrad, yrad, xx, yy, chg, n; magic_api *api = (magic_api *) ptr; @@ -336,18 +336,24 @@ void bloom_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, if (snd_effects != NULL) api->playsound(snd_effects, (x * 255) / canvas->w, 255); - for (yrad = -BLOOM_PAINT_RADIUS; yrad < BLOOM_PAINT_RADIUS; yrad++) { + for (yrad = -BLOOM_PAINT_RADIUS; yrad < BLOOM_PAINT_RADIUS; yrad++) + { yy = y + yrad; - if (yy >= 0 && yy < canvas->h) { - for (xrad = -BLOOM_PAINT_RADIUS; xrad < BLOOM_PAINT_RADIUS; xrad++) { + if (yy >= 0 && yy < canvas->h) + { + for (xrad = -BLOOM_PAINT_RADIUS; xrad < BLOOM_PAINT_RADIUS; xrad++) + { xx = x + xrad; - if (xx >= 0 && xx < canvas->w) { - if (api->in_circle(xrad, yrad, BLOOM_PAINT_RADIUS)) { + if (xx >= 0 && xx < canvas->w) + { + if (api->in_circle(xrad, yrad, BLOOM_PAINT_RADIUS)) + { /* Add to the bloom mask */ - n = (int) bloom_mask[yy * canvas->w + xx]; + n = (int)bloom_mask[yy * canvas->w + xx]; chg = sqrt(bloom_scale - sqrt((xrad * xrad) + (yrad * yrad))); n += chg; - if (n > 255) { + if (n > 255) + { n = 255; } bloom_mask[yy * canvas->w + xx] = (Uint8) n; @@ -363,29 +369,29 @@ void bloom_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, void bloom_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, int mode, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, int mode, SDL_Surface * canvas ATTRIBUTE_UNUSED) { if (bloom_mask == NULL) - bloom_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas-> w * canvas->h); + bloom_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); if (mode == MODE_FULLSCREEN) bloom_set_size(api, which, mode, NULL, NULL, bloom_default_size(api, which, mode), NULL); } void bloom_switchout(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { } -float luminance(float r, float g, float b) { +float luminance(float r, float g, float b) +{ return (r * 0.2126) + (g * 0.7152) + (b * 0.0722); } -float change_luminance(float c_in, float l_in, float l_out) { - return c_in * (l_out / l_in); +float change_luminance(float c_in, float l_in, float l_out) +{ + return c_in * (l_out / l_in); } @@ -402,7 +408,9 @@ Uint8 bloom_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 2; } -void bloom_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 bloom_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) { BLOOM_PAINT_RADIUS = size * 12; BLOOM_SPIKE_LENGTH = sqrt(BLOOM_PAINT_RADIUS + 1); diff --git a/magic/src/blur.c b/magic/src/blur.c index 36d35905a..c070b3ad1 100644 --- a/magic/src/blur.c +++ b/magic/src/blur.c @@ -46,8 +46,7 @@ char *blur_get_name(magic_api * api, int which); int blur_get_group(magic_api * api, int which); char *blur_get_description(magic_api * api, int which, int mode); void blur_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); void blur_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void blur_release(magic_api * api, int which, SDL_Surface * canvas, @@ -60,10 +59,8 @@ void blur_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, int blur_requires_colors(magic_api * api, int which); Uint8 blur_accepted_sizes(magic_api * api, int which, int mode); Uint8 blur_default_size(magic_api * api, int which, int mode); -void blur_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void blur_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void blur_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void blur_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int blur_modes(magic_api * api, int which); enum @@ -110,8 +107,7 @@ int blur_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < blur_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - blur_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, blur_snd_filenames[i]); blur_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -127,8 +123,7 @@ SDL_Surface *blur_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - blur_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, blur_icon_filenames[which]); return (IMG_Load(fname)); } @@ -145,16 +140,13 @@ int blur_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *blur_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *blur_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(blur_descs[which][mode - 1]))); } //Do the effect for one pixel -static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, - int y) +static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int i, j, k; @@ -179,8 +171,7 @@ static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED, for (j = -2; j < 3; j++) { //Add the pixels around the current one wieghted - SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], - &temp[1], &temp[2]); + SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], &temp[1], &temp[2]); for (k = 0; k < 3; k++) { blurValue[k] += temp[k] * weight[i + 2][j + 2]; @@ -191,14 +182,11 @@ static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED, { blurValue[k] /= 273; } - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], - blurValue[2])); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], blurValue[2])); } // Do the effect for the full image -static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which) +static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which) { magic_api *api = (magic_api *) ptr; int x, y; @@ -218,8 +206,7 @@ static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, } //do the effect for the brush -static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; magic_api *api = (magic_api *) ptr; @@ -228,8 +215,7 @@ static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas, { for (xx = x - blur_RADIUS; xx < x + blur_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, blur_RADIUS) - && !api->touched(xx, yy)) + if (api->in_circle(xx - x, yy - y, blur_RADIUS) && !api->touched(xx, yy)) { do_blur_pixel(api, which, canvas, last, xx, yy); } @@ -239,12 +225,10 @@ static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void blur_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_blur_brush); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_blur_brush); api->playsound(blur_snd_effect[which], (x * 255) / canvas->w, 255); @@ -271,8 +255,7 @@ void blur_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void blur_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) blur_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -292,8 +275,7 @@ void blur_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) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -314,45 +296,46 @@ void blur_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void blur_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 * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, + Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } // Record the size from Tux Paint: void blur_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 sz, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { + Uint8 sz, SDL_Rect * update_rect ATTRIBUTE_UNUSED) +{ blur_RADIUS = sz * 4; } // Use colors: -int blur_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int blur_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -Uint8 blur_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { +Uint8 blur_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) +{ if (mode == MODE_PAINT) return 8; else return 0; } -Uint8 blur_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { +Uint8 blur_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +{ return 4; } void blur_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 blur_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) { } diff --git a/magic/src/bricks.c b/magic/src/bricks.c index b0e2038a2..2e87050a4 100644 --- a/magic/src/bricks.c +++ b/magic/src/bricks.c @@ -55,8 +55,7 @@ static int brick_size = TOOL_LARGEBRICKS; /* Local function prototype: */ -static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, - int w, int h); +static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, int w, int h); int bricks_init(magic_api * api, Uint32 disabled_features); Uint32 bricks_api_version(void); int bricks_get_tool_count(magic_api * api); @@ -65,8 +64,7 @@ char *bricks_get_name(magic_api * api, int which); int bricks_get_group(magic_api * api, int which); char *bricks_get_description(magic_api * api, int which, int mode); void bricks_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); void bricks_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void bricks_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); //An empty function. Is there a purpose to this? Ask moderator. @@ -74,22 +72,20 @@ void bricks_shutdown(magic_api * api); void bricks_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int bricks_requires_colors(magic_api * api, int which); -void bricks_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void bricks_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void bricks_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void bricks_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int bricks_modes(magic_api * api, int which); Uint8 bricks_accepted_sizes(magic_api * api, int which, int mode); Uint8 bricks_default_size(magic_api * api, int which, int mode); -void bricks_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void bricks_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: int bricks_init(magic_api * api, Uint32 disabled_features) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/brick.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/brick.wav", api->data_directory); brick_snd = Mix_LoadWAV(fname); if (disabled_features & MAGIC_FEATURE_SIZE) @@ -121,21 +117,18 @@ SDL_Surface *bricks_get_icon(magic_api * api, int which) if (which == TOOL_LARGEBRICKS) { - snprintf(fname, sizeof(fname), "%simages/magic/largebrick.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/largebrick.png", api->data_directory); } else if (which == TOOL_SMALLBRICKS) { - snprintf(fname, sizeof(fname), "%simages/magic/smallbrick.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/smallbrick.png", api->data_directory); } return (IMG_Load(fname)); } // Return our names, localized: -char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { /* Both are named "Bricks", at the moment: */ @@ -143,22 +136,23 @@ char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED, } // Return our group (both the same): -int bricks_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int bricks_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { - if (brick_two_tools) { + if (brick_two_tools) + { if (which == TOOL_LARGEBRICKS) return (strdup(gettext_noop("Click and drag to draw large bricks."))); else if (which == TOOL_SMALLBRICKS) return (strdup(gettext_noop("Click and drag to draw small bricks."))); - } else { + } + else + { return (strdup(gettext_noop("Click and drag to draw bricks."))); } @@ -167,8 +161,7 @@ char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, // Do the effect: -static void do_bricks(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) +static void do_bricks(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -215,8 +208,7 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas, mybrick = map + brick_x + 1 + (brick_y + 1) * x_count; - if ((unsigned) x < (unsigned) canvas->w - && (unsigned) y < (unsigned) canvas->h && !*mybrick) + if ((unsigned)x < (unsigned)canvas->w && (unsigned)y < (unsigned)canvas->h && !*mybrick) { int my_x = brick_x * nominal_width; int my_w = specified_width; @@ -237,8 +229,7 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas, my_x -= nominal_width; my_w = specified_length; } - do_brick(api, canvas, my_x, brick_y * nominal_height, my_w, - specified_height); + do_brick(api, canvas, my_x, brick_y * nominal_height, my_w, specified_height); // FIXME: @@ -258,10 +249,9 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void bricks_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_bricks); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_bricks); if (ox > x) { @@ -290,8 +280,7 @@ void bricks_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void bricks_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) { bricks_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -300,8 +289,7 @@ void bricks_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -313,8 +301,9 @@ void bricks_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void bricks_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 bricks_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) { bricks_r = r; bricks_g = g; @@ -322,29 +311,21 @@ void bricks_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS } // Use colors: -int bricks_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int bricks_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } -static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, - int w, int h) +static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, int w, int h) { SDL_Rect dest; // brick color: 127,76,73 - double ran_r = rand() / (double) RAND_MAX; - double ran_g = rand() / (double) RAND_MAX; - double base_r = - api->sRGB_to_linear(bricks_r) * 1.5 + api->sRGB_to_linear(127) * 5.0 + - ran_r; - double base_g = - api->sRGB_to_linear(bricks_g) * 1.5 + api->sRGB_to_linear(76) * 5.0 + - ran_g; - double base_b = - api->sRGB_to_linear(bricks_b) * 1.5 + api->sRGB_to_linear(73) * 5.0 + - (ran_r + ran_g * 2.0) / 3.0; + double ran_r = rand() / (double)RAND_MAX; + double ran_g = rand() / (double)RAND_MAX; + double base_r = api->sRGB_to_linear(bricks_r) * 1.5 + api->sRGB_to_linear(127) * 5.0 + ran_r; + double base_g = api->sRGB_to_linear(bricks_g) * 1.5 + api->sRGB_to_linear(76) * 5.0 + ran_g; + double base_b = api->sRGB_to_linear(bricks_b) * 1.5 + api->sRGB_to_linear(73) * 5.0 + (ran_r + ran_g * 2.0) / 3.0; Uint8 r = api->linear_to_sRGB(base_r / 7.5); Uint8 g = api->linear_to_sRGB(base_g / 7.5); @@ -365,14 +346,12 @@ static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, } void bricks_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 bricks_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) { } @@ -392,10 +371,16 @@ Uint8 bricks_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 2; } -void bricks_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) { - if (size == 1) { +void bricks_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) +{ + if (size == 1) + { brick_size = TOOL_SMALLBRICKS; - } else { // 2 + } + else + { // 2 brick_size = TOOL_LARGEBRICKS; } } diff --git a/magic/src/calligraphy.c b/magic/src/calligraphy.c index d4425a7fe..51f615e86 100644 --- a/magic/src/calligraphy.c +++ b/magic/src/calligraphy.c @@ -49,8 +49,7 @@ static SDL_Surface *calligraphy_brush, *calligraphy_colored_brush; /* Local Function Prototypes */ static Point2D calligraphy_PointOnCubicBezier(Point2D * cp, float t); -static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve); +static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve); static float calligraphy_dist(float x1, float y1, float x2, float y2); int calligraphy_init(magic_api * api, Uint32 disabled_features); Uint32 calligraphy_api_version(void); @@ -60,26 +59,22 @@ char *calligraphy_get_name(magic_api * api, int which); int calligraphy_get_group(magic_api * api, int which); char *calligraphy_get_description(magic_api * api, int which, int mode); void calligraphy_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); void calligraphy_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 calligraphy_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void calligraphy_shutdown(magic_api * api); void calligraphy_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int calligraphy_requires_colors(magic_api * api, int which); -void calligraphy_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void calligraphy_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void calligraphy_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void calligraphy_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int calligraphy_modes(magic_api * api, int which); Uint8 calligraphy_accepted_sizes(magic_api * api, int which, int mode); Uint8 calligraphy_default_size(magic_api * api, int which, int mode); -void calligraphy_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void calligraphy_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -87,13 +82,11 @@ int calligraphy_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/calligraphy.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/calligraphy.ogg", api->data_directory); calligraphy_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%simages/magic/calligraphy_brush.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/calligraphy_brush.png", api->data_directory); calligraphy_brush = IMG_Load(fname); calligraphy_colored_brush = NULL; @@ -127,40 +120,33 @@ SDL_Surface *calligraphy_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/calligraphy.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/calligraphy.png", api->data_directory); return (IMG_Load(fname)); } // Return our name, localized: -char *calligraphy_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *calligraphy_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Calligraphy"))); } // Return our group -int calligraphy_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int calligraphy_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our description, localized: char *calligraphy_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to draw in calligraphy."))); + return (strdup(gettext_noop("Click and drag the mouse around to draw in calligraphy."))); } void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, - int x, int y, SDL_Rect * update_rect) + SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y, SDL_Rect * update_rect) { Point2D *curve; int i, n_points, thick, new_thick; @@ -200,9 +186,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, calligraphy_control_points[2].x, calligraphy_control_points[2].y) + calligraphy_dist(calligraphy_control_points[2].x, - calligraphy_control_points[2].y, - calligraphy_control_points[3].x, - calligraphy_control_points[3].y); + calligraphy_control_points[2].y, calligraphy_control_points[3].x, calligraphy_control_points[3].y); if (n_points == 0) return; // No-op; not any points to plot @@ -216,8 +200,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, for (i = 0; i < n_points - 1; i++) { - thick = - ((new_thick * i) + (calligraphy_old_thick * (n_points - i))) / n_points; + thick = ((new_thick * i) + (calligraphy_old_thick * (n_points - i))) / n_points; /* The new way, using an antialiased brush bitmap */ @@ -286,8 +269,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, void calligraphy_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { calligraphy_old_thick = 8; calligraphy_last_time = 0; @@ -307,8 +289,7 @@ void calligraphy_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -325,7 +306,8 @@ void calligraphy_shutdown(magic_api * api ATTRIBUTE_UNUSED) // We don't use colors void calligraphy_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { int x, y; Uint8 a; @@ -341,9 +323,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf if (calligraphy_colored_brush != NULL) SDL_FreeSurface(calligraphy_colored_brush); - amask = - ~(calligraphy_brush->format->Rmask | calligraphy_brush->format-> - Gmask | calligraphy_brush->format->Bmask); + amask = ~(calligraphy_brush->format->Rmask | calligraphy_brush->format->Gmask | calligraphy_brush->format->Bmask); calligraphy_colored_brush = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -351,8 +331,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf calligraphy_brush->h, calligraphy_brush->format->BitsPerPixel, calligraphy_brush->format->Rmask, - calligraphy_brush->format->Gmask, - calligraphy_brush->format->Bmask, amask); + calligraphy_brush->format->Gmask, calligraphy_brush->format->Bmask, amask); if (calligraphy_colored_brush == NULL) return; // FIXME: Error! @@ -365,13 +344,10 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf { for (x = 0; x < calligraphy_brush->w; x++) { - SDL_GetRGBA(api->getpixel(calligraphy_brush, x, y), - calligraphy_brush->format, &r, &g, &b, &a); + SDL_GetRGBA(api->getpixel(calligraphy_brush, x, y), calligraphy_brush->format, &r, &g, &b, &a); api->putpixel(calligraphy_colored_brush, x, y, - SDL_MapRGBA(calligraphy_colored_brush->format, - calligraphy_r, calligraphy_g, calligraphy_b, - a)); + SDL_MapRGBA(calligraphy_colored_brush->format, calligraphy_r, calligraphy_g, calligraphy_b, a)); } } @@ -380,8 +356,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf } // We don't use colors -int calligraphy_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int calligraphy_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -436,8 +411,7 @@ static Point2D calligraphy_PointOnCubicBezier(Point2D * cp, float t) */ -static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve) +static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve) { float dt; int i; @@ -458,27 +432,23 @@ static float calligraphy_dist(float x1, float y1, float x2, float y2) } void calligraphy_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 calligraphy_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 calligraphy_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int calligraphy_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } -Uint8 calligraphy_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 calligraphy_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } @@ -488,6 +458,8 @@ Uint8 calligraphy_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI return 0; } -void calligraphy_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 calligraphy_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) { } diff --git a/magic/src/cartoon.c b/magic/src/cartoon.c index 955d59df6..1f4a4dd0c 100644 --- a/magic/src/cartoon.c +++ b/magic/src/cartoon.c @@ -51,31 +51,26 @@ SDL_Surface *cartoon_get_icon(magic_api * api, int which); char *cartoon_get_name(magic_api * api, int which); int cartoon_get_group(magic_api * api, int which); char *cartoon_get_description(magic_api * api, int which, int mode); -void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx, - int yy); +void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx, int yy); void cartoon_apply_outline(magic_api * api, int xx, int yy); -static void do_cartoon(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_cartoon(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void cartoon_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); void cartoon_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void cartoon_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void cartoon_shutdown(magic_api * api); void cartoon_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int cartoon_requires_colors(magic_api * api, int which); -void cartoon_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void cartoon_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void cartoon_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void cartoon_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int cartoon_modes(magic_api * api, int which); Uint8 cartoon_accepted_sizes(magic_api * api, int which, int mode); Uint8 cartoon_default_size(magic_api * api, int which, int mode); -void cartoon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void cartoon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: @@ -83,8 +78,7 @@ int cartoon_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/cartoon.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/cartoon.wav", api->data_directory); cartoon_snd = Mix_LoadWAV(fname); return (1); @@ -106,41 +100,33 @@ SDL_Surface *cartoon_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/cartoon.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/cartoon.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *cartoon_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *cartoon_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Cartoon"))); } // Return our groups -int cartoon_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int cartoon_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_COLOR_FILTERS; } // Return our descriptions, localized: -char *cartoon_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *cartoon_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to turn the picture into a cartoon."))); + return (strdup(gettext_noop("Click and drag the mouse around to turn the picture into a cartoon."))); } else { - return (strdup - (gettext_noop - ("Click to turn the entire picture into a cartoon."))); + return (strdup(gettext_noop("Click to turn the entire picture into a cartoon."))); } } @@ -168,8 +154,7 @@ void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx, int yy) sat = floor(sat * 4) / 4; api->hsvtorgb(hue, sat, val, &r, &g, &b); - api->putpixel(result_surf, xx, yy, - SDL_MapRGB(result_surf->format, r, g, b)); + api->putpixel(result_surf, xx, yy, SDL_MapRGB(result_surf->format, r, g, b)); } @@ -178,34 +163,26 @@ void cartoon_apply_outline(magic_api * api, int xx, int yy) Uint8 r, g, b; Uint8 r1, g1, b1, r2, g2, b2; - SDL_GetRGB(api->getpixel(result_surf, xx, yy), result_surf->format, &r, &g, - &b); - SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy), result_surf->format, &r1, - &g1, &b1); - SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy + 1), result_surf->format, - &r2, &g2, &b2); + SDL_GetRGB(api->getpixel(result_surf, xx, yy), result_surf->format, &r, &g, &b); + SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy), result_surf->format, &r1, &g1, &b1); + SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy + 1), result_surf->format, &r2, &g2, &b2); if (abs(((r + g + b) / 3) - (r1 + g1 + b1) / 3) > OUTLINE_THRESH || abs(((r + g + b) / 3) - (r2 + g2 + b2) / 3) > OUTLINE_THRESH || abs(r - r1) > OUTLINE_THRESH || abs(g - g1) > OUTLINE_THRESH || abs(b - b1) > OUTLINE_THRESH - || abs(r - r2) > OUTLINE_THRESH || abs(g - g2) > OUTLINE_THRESH - || abs(b - b2) > OUTLINE_THRESH) + || abs(r - r2) > OUTLINE_THRESH || abs(g - g2) > OUTLINE_THRESH || abs(b - b2) > OUTLINE_THRESH) { - api->putpixel(result_surf, xx - 1, yy, - SDL_MapRGB(result_surf->format, 0, 0, 0)); - api->putpixel(result_surf, xx, yy - 1, - SDL_MapRGB(result_surf->format, 0, 0, 0)); - api->putpixel(result_surf, xx - 1, yy - 1, - SDL_MapRGB(result_surf->format, 0, 0, 0)); + api->putpixel(result_surf, xx - 1, yy, SDL_MapRGB(result_surf->format, 0, 0, 0)); + api->putpixel(result_surf, xx, yy - 1, SDL_MapRGB(result_surf->format, 0, 0, 0)); + api->putpixel(result_surf, xx - 1, yy - 1, SDL_MapRGB(result_surf->format, 0, 0, 0)); } } static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -224,8 +201,7 @@ static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void cartoon_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) { if (ox > x) { @@ -242,7 +218,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas, y = tmp; } - api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_cartoon); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_cartoon); update_rect->x = ox - cartoon_radius; update_rect->y = oy - cartoon_radius; @@ -254,8 +230,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void cartoon_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) { for (y = 0; y < canvas->h; y++) { @@ -303,8 +278,7 @@ void cartoon_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -316,46 +290,41 @@ void cartoon_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void cartoon_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) +void cartoon_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) { } // Use colors: -int cartoon_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int cartoon_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void cartoon_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { Uint32 amask; - amask = - ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); + amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); result_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); } void cartoon_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) { if (result_surf != NULL) SDL_FreeSurface(result_surf); } -int cartoon_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int cartoon_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } @@ -374,7 +343,9 @@ Uint8 cartoon_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 4; } -void cartoon_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 cartoon_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) { cartoon_radius = size * 4; } diff --git a/magic/src/checkerboard.c b/magic/src/checkerboard.c index 89a0d8833..d194b5b90 100644 --- a/magic/src/checkerboard.c +++ b/magic/src/checkerboard.c @@ -49,26 +49,24 @@ int checkerboard_get_group(magic_api * api, int which); char *checkerboard_get_description(magic_api * api, int which, int mode); int checkerboard_requires_colors(magic_api * api, int which); void checkerboard_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 checkerboard_shutdown(magic_api * api); void checkerboard_paint_checkerboard(void *ptr_to_api, int which_tool, - SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void checkerboard_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 checkerboard_click(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last, int x, - int y, SDL_Rect * update_rect); -void checkerboard_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void checkerboard_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 checkerboard_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void checkerboard_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int checkerboard_modes(magic_api * api, int which); -Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); -Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); -void checkerboard_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); +Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED); +Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED); +void checkerboard_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); // Housekeeping functions @@ -77,8 +75,9 @@ Uint32 checkerboard_api_version(void) return (TP_MAGIC_API_VERSION); } -void checkerboard_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 checkerboard_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 checkerboard_r = r; @@ -90,8 +89,7 @@ int checkerboard_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/checkerboard.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/checkerboard.ogg", api->data_directory); checkerboard_snd = Mix_LoadWAV(fname); return (1); @@ -102,40 +100,32 @@ int checkerboard_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) return 1; } -SDL_Surface *checkerboard_get_icon(magic_api * api, - int which ATTRIBUTE_UNUSED) +SDL_Surface *checkerboard_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/checkerboard.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/checkerboard.png", api->data_directory); return (IMG_Load(fname)); } -char *checkerboard_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *checkerboard_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Checkerboard")); } -int checkerboard_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int checkerboard_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_DECORATIONS; } char *checkerboard_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext_noop - ("Click and drag to fill the canvas with a checkerboard pattern.")); + return strdup(gettext_noop("Click and drag to fill the canvas with a checkerboard pattern.")); } -int checkerboard_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int checkerboard_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -144,8 +134,7 @@ void checkerboard_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) { } @@ -158,8 +147,7 @@ void checkerboard_shutdown(magic_api * api ATTRIBUTE_UNUSED) void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, - int x, int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int sz, xx, yy; Uint8 draw_start, draw_row, draw_cell; @@ -168,13 +156,9 @@ void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_BlitSurface(snapshot, NULL, canvas, NULL); - sz = - max(10, - max(abs(x - checkerboard_start_x), abs(y - checkerboard_start_y))); + sz = max(10, max(abs(x - checkerboard_start_x), abs(y - checkerboard_start_y))); - colr = - SDL_MapRGB(canvas->format, checkerboard_r, checkerboard_g, - checkerboard_b); + colr = SDL_MapRGB(canvas->format, checkerboard_r, checkerboard_g, checkerboard_b); draw_start = 1; if (x < checkerboard_start_x) @@ -267,8 +251,7 @@ void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED, void checkerboard_click(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect) + SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { checkerboard_start_x = x; checkerboard_start_y = y; @@ -276,26 +259,23 @@ void checkerboard_click(magic_api * api, int which ATTRIBUTE_UNUSED, } void checkerboard_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 checkerboard_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { } -int checkerboard_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int checkerboard_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } -Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } @@ -305,6 +285,8 @@ Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTR return 0; } -void checkerboard_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 checkerboard_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) { } diff --git a/magic/src/clone.c b/magic/src/clone.c index 365c51c83..45b4c18e6 100644 --- a/magic/src/clone.c +++ b/magic/src/clone.c @@ -73,11 +73,9 @@ char *clone_get_name(magic_api * api, int which); int clone_get_group(magic_api * api, int which); char *clone_get_description(magic_api * api, int which, int mode); void clone_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); void clone_doit(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y, - SDL_Rect * update_rect, int crosshairs); + SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs); void clone_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void clone_release(magic_api * api, int which, SDL_Surface * canvas, @@ -86,29 +84,25 @@ void clone_shutdown(magic_api * api); void clone_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int clone_requires_colors(magic_api * api, int which); -void clone_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void clone_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void clone_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void clone_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int clone_modes(magic_api * api, int which); void clone_crosshairs(magic_api * api, SDL_Surface * canvas, int x, int y); -void done_cloning(magic_api * api, SDL_Surface * canvas, - SDL_Rect * update_rect); +void done_cloning(magic_api * api, SDL_Surface * canvas, SDL_Rect * update_rect); Uint8 clone_accepted_sizes(magic_api * api, int which, int mode); Uint8 clone_default_size(magic_api * api, int which, int mode); -void clone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void clone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: int clone_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/clone_start.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/clone_start.ogg", api->data_directory); clone_start_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/clone.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/clone.ogg", api->data_directory); clone_snd = Mix_LoadWAV(fname); clone_state = CLONE_READY_TO_START; @@ -133,30 +127,25 @@ SDL_Surface *clone_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/clone.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/clone.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *clone_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *clone_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Clone"))); } // Return our groups: -int clone_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int clone_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return (strdup (gettext_noop @@ -167,8 +156,7 @@ char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect: -static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, int y) +static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int yy, dx; @@ -206,8 +194,7 @@ static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void clone_drag(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, - int y, SDL_Rect * update_rect) + SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y, SDL_Rect * update_rect) { /* Step 3 - Actively cloning (moving the mouse) */ @@ -221,8 +208,7 @@ void clone_drag(magic_api * api, int which, SDL_Surface * canvas, } void clone_doit(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y, - SDL_Rect * update_rect, int crosshairs) + SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs) { if (clone_state != CLONE_CLONING) return; @@ -230,7 +216,7 @@ void clone_doit(magic_api * api, int which, SDL_Surface * canvas, clone_drag_start_x = ox; clone_drag_start_y = oy; - api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_clone); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_clone); /* Move source position relative to mouse motion */ clone_src_x += (x - ox); @@ -275,8 +261,7 @@ void clone_doit(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void clone_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) { if (clone_state == CLONE_READY_TO_START) { @@ -306,8 +291,7 @@ void clone_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void clone_release(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) { if (clone_state == CLONE_STARTING) { @@ -321,8 +305,7 @@ void clone_release(magic_api * api, int which ATTRIBUTE_UNUSED, } } -void done_cloning(magic_api * api, SDL_Surface * canvas, - SDL_Rect * update_rect) +void done_cloning(magic_api * api, SDL_Surface * canvas, SDL_Rect * update_rect) { /* Done cloning! */ @@ -361,32 +344,30 @@ void clone_shutdown(magic_api * api ATTRIBUTE_UNUSED) Mix_FreeChunk(clone_start_snd); } -void clone_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) +void clone_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) { } -int clone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int clone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void clone_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) { clone_last = SDL_CreateRGBSurface(0, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); clone_state = CLONE_READY_TO_START; } -void clone_switchout(magic_api * api, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) +void clone_switchout(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { SDL_Rect update_rect; /* Needed to satisfy done_cloning() :-( */ @@ -402,15 +383,19 @@ int clone_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) } -Uint8 clone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { +Uint8 clone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +{ return 8; } -Uint8 clone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { +Uint8 clone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +{ return 2; } -void clone_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 clone_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) { clone_radius = size * 8; } diff --git a/magic/src/colorsep.c b/magic/src/colorsep.c index ae7ed9011..c2052ecc9 100644 --- a/magic/src/colorsep.c +++ b/magic/src/colorsep.c @@ -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) { } diff --git a/magic/src/confetti.c b/magic/src/confetti.c index 69c9f2c15..25bfdbe39 100644 --- a/magic/src/confetti.c +++ b/magic/src/confetti.c @@ -8,7 +8,8 @@ #include "SDL_image.h" #include "SDL_mixer.h" -static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle +static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle + #define CONFETTI_QUANTITY 3 //how many circles will be created every click? #ifdef __ANDROID__ @@ -36,37 +37,34 @@ int confetti_get_group(magic_api * api, int which); char *confetti_get_description(magic_api * api, int which, int mode); int confetti_requires_colors(magic_api * api, int which); void confetti_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 confetti_shutdown(magic_api * api); inline char confetti_get_greater(const char what1, const char what2); inline char confetti_get_lesser(const char what1, const char what2); Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas); void confetti_click(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); -void confetti_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void confetti_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 confetti_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void confetti_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int confetti_modes(magic_api * api, int which); // Housekeeping functions void confetti_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); Uint8 confetti_accepted_sizes(magic_api * api, int which, int mode); Uint8 confetti_default_size(magic_api * api, int which, int mode); -void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 confetti_api_version(void) { return (TP_MAGIC_API_VERSION); } -void confetti_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 confetti_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 confetti_colors.r = r; @@ -78,8 +76,7 @@ int confetti_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg", api->data_directory); confetti_snd = Mix_LoadWAV(fname); return (1); @@ -94,33 +91,27 @@ SDL_Surface *confetti_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/confetti.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/confetti.png", api->data_directory); return (IMG_Load(fname)); } -char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Confetti")); } -int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } -char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Click to throw confetti!")); } -int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -129,8 +120,7 @@ void confetti_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) { } @@ -183,27 +173,23 @@ Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas) //this function static void confetti_circle(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; Uint32 color = confetti_get_new_color(api, canvas); - for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2; - yy++) + for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2; yy++) - for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2; - xx++) + for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2; xx++) if (api->in_circle(xx - x, yy - y, CONFETTI_BRUSH_SIZE / 2)) api->putpixel(canvas, xx, yy, color); } void confetti_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) { unsigned char i; char min_x = 0, max_x = 0, min_y = 0, max_y = 0; @@ -212,8 +198,8 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, for (i = 0; i < CONFETTI_QUANTITY; i++) { srand((dx + dy) / 2 + time(0)); //to get a unique seed even if dx and dy aren't defined - dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50> - dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position + dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50> + dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position if (!i) { @@ -227,7 +213,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, min_y = confetti_get_lesser(min_y, dy); max_y = confetti_get_greater(max_y, dy); } - confetti_circle((void *) api, which, canvas, last, x + dx, y + dy); + confetti_circle((void *)api, which, canvas, last, x + dx, y + dy); } update_rect->x = x + min_x - CONFETTI_BRUSH_SIZE / 2; @@ -239,8 +225,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, } void confetti_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) { int temp; @@ -261,19 +246,16 @@ void confetti_drag(magic_api * api, int which, SDL_Surface * canvas, } void confetti_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 confetti_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 confetti_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int confetti_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -289,7 +271,9 @@ Uint8 confetti_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT return 2; } -void confetti_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 confetti_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) { CONFETTI_BRUSH_SIZE = size * 4; } diff --git a/magic/src/distortion.c b/magic/src/distortion.c index b148cf909..db398feef 100644 --- a/magic/src/distortion.c +++ b/magic/src/distortion.c @@ -65,31 +65,25 @@ int distortion_requires_colors(magic_api * api, int which); void distortion_shutdown(magic_api * api); void distortion_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 distortion_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); void distortion_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); -void distortion_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void distortion_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void distortion_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void distortion_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int distortion_modes(magic_api * api, int which); void distortion_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); -static void distortion_line_callback(void *ptr, int which, - SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +static void distortion_line_callback(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); Uint8 distortion_accepted_sizes(magic_api * api, int which, int mode); Uint8 distortion_default_size(magic_api * api, int which, int mode); -void distortion_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void distortion_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); /* Setup Functions: */ @@ -107,8 +101,7 @@ int distortion_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/distortion.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/distortion.ogg", api->data_directory); // Try to load the file! @@ -132,8 +125,7 @@ SDL_Surface *distortion_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/distortion.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/distortion.png", api->data_directory); // Try to load the image, and return the results to Tux Paint: @@ -144,8 +136,7 @@ SDL_Surface *distortion_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) // Report our "Magic" tool names -char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Distortion"))); } @@ -153,8 +144,7 @@ char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED, // Report our "Magic" tool groups -int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } @@ -163,18 +153,14 @@ int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED, // Report our "Magic" tool descriptions char *distortion_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag the mouse to cause distortion in your picture."))); + return (strdup(gettext_noop("Click and drag the mouse to cause distortion in your picture."))); } // Report whether we accept colors -int distortion_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int distortion_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -194,8 +180,7 @@ void distortion_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Affect the canvas on click: void distortion_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) { distortion_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); } @@ -204,11 +189,9 @@ void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on drag: void distortion_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, - distortion_line_callback); + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, distortion_line_callback); if (ox > x) @@ -244,14 +227,15 @@ void distortion_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) { } -void distortion_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) +void distortion_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) { } @@ -259,8 +243,7 @@ void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ // Our "callback" function static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y) + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -276,29 +259,23 @@ static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, { if (api->in_circle(xx, yy, distortion_radius)) { - api->putpixel(canvas, x + xx, y + yy, - api->getpixel(snapshot, x + xx / 2, y + yy)); + api->putpixel(canvas, x + xx, y + yy, api->getpixel(snapshot, x + xx / 2, y + yy)); } } } } void distortion_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 distortion_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 distortion_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int distortion_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -314,7 +291,9 @@ Uint8 distortion_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB return 2; } -void distortion_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 distortion_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) { distortion_radius = size * 4; } diff --git a/magic/src/emboss.c b/magic/src/emboss.c index c2b062076..2fb553d07 100644 --- a/magic/src/emboss.c +++ b/magic/src/emboss.c @@ -47,29 +47,25 @@ int emboss_get_group(magic_api * api, int which); char *emboss_get_description(magic_api * api, int which, int mode); void emboss_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); void emboss_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 emboss_release(magic_api * api, int which, - 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 emboss_shutdown(magic_api * api); void emboss_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int emboss_requires_colors(magic_api * api, int which); -void emboss_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void emboss_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void emboss_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void emboss_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int emboss_modes(magic_api * api, int which); Uint8 emboss_accepted_sizes(magic_api * api, int which, int mode); Uint8 emboss_default_size(magic_api * api, int which, int mode); -void emboss_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void emboss_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 emboss_api_version(void) @@ -83,8 +79,7 @@ int emboss_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/emboss.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/emboss.ogg", api->data_directory); emboss_snd = Mix_LoadWAV(fname); return (1); @@ -101,34 +96,28 @@ SDL_Surface *emboss_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/emboss.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/emboss.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *emboss_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *emboss_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Emboss"))); } // Return our groups: -int emboss_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int emboss_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return (strdup - (gettext_noop - ("Click and drag the mouse to emboss the picture."))); + return (strdup(gettext_noop("Click and drag the mouse to emboss the picture."))); else return (strdup(gettext_noop("Click to emboss the entire picture."))); } @@ -136,8 +125,7 @@ char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect (single pixel; used by do_emboss() (painted circle) // and emboss_click() when in fullscreen mode): -static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y, - SDL_Surface * canvas) +static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y, SDL_Surface * canvas) { magic_api *api = (magic_api *) ptr; Uint8 r1, g1, b1, r2, g2, b2; @@ -168,8 +156,7 @@ static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y, // Do the effect (a circle around a touch point): -static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, int y) +static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -191,10 +178,9 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void emboss_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_emboss); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_emboss); if (ox > x) { @@ -221,8 +207,7 @@ void emboss_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void emboss_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) { @@ -255,8 +240,7 @@ void emboss_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -268,27 +252,26 @@ void emboss_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void emboss_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) +void emboss_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) { } // Use colors: -int emboss_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int emboss_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void emboss_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 emboss_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) { } @@ -311,7 +294,9 @@ Uint8 emboss_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 4; } -void emboss_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 emboss_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) { emboss_radius = size * 4; } diff --git a/magic/src/fade_darken.c b/magic/src/fade_darken.c index d59a6a2fb..94dc99022 100644 --- a/magic/src/fade_darken.c +++ b/magic/src/fade_darken.c @@ -43,7 +43,7 @@ enum NUM_TOOLS }; -char * tool_names[NUM_TOOLS] = { +char *tool_names[NUM_TOOLS] = { gettext_noop("Lighten"), gettext_noop("Darken"), gettext_noop("Desaturate"), @@ -52,34 +52,31 @@ char * tool_names[NUM_TOOLS] = { gettext_noop("Keep Color"), }; -char * tool_descriptions[NUM_TOOLS][2] = { +char *tool_descriptions[NUM_TOOLS][2] = { { gettext_noop("Click and drag the mouse to lighten parts of your picture."), - gettext_noop("Click to lighten your entire picture.") - }, + gettext_noop("Click to lighten your entire picture.")}, { gettext_noop("Click and drag the mouse to darken parts of your picture."), - gettext_noop("Click to darken your entire picture.") - }, + gettext_noop("Click to darken your entire picture.")}, { gettext_noop("Click and drag the mouse to desaturate parts of your picture."), - gettext_noop("Click to desaturate your entire picture.") - }, + gettext_noop("Click to desaturate your entire picture.")}, { gettext_noop("Click and drag the mouse to saturate parts of your picture."), - gettext_noop("Click to saturate your entire picture.") - }, + gettext_noop("Click to saturate your entire picture.")}, { gettext_noop("Click and drag the mouse to entirely desaturate parts of your picture that match the chosen color."), gettext_noop("Click to entirely desaturate the parts of your picture that match the chosen color."), - }, + }, { - gettext_noop("Click and drag the mouse to entirely desaturate parts of your picture that don't match the chosen color."), + gettext_noop + ("Click and drag the mouse to entirely desaturate parts of your picture that don't match the chosen color."), gettext_noop("Click to entirely desaturate the parts of your picture that don't match the chosen color."), - }, + }, }; -char * sfx_filenames[NUM_TOOLS] = { +char *sfx_filenames[NUM_TOOLS] = { "fade.wav", "darken.wav", "desaturate.ogg", @@ -88,7 +85,7 @@ char * sfx_filenames[NUM_TOOLS] = { "keep_color.ogg", }; -char * icon_filenames[NUM_TOOLS] = { +char *icon_filenames[NUM_TOOLS] = { "fade.png", "darken.png", "desaturate.png", @@ -117,31 +114,25 @@ SDL_Surface *fade_darken_get_icon(magic_api * api, int which); int fade_darken_get_group(magic_api * api, int which); char *fade_darken_get_name(magic_api * api, int which); char *fade_darken_get_description(magic_api * api, int which, int mode); -static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void fade_darken_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); void fade_darken_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 fade_darken_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void fade_darken_shutdown(magic_api * api); void fade_darken_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int fade_darken_requires_colors(magic_api * api, int which); -void fade_darken_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void fade_darken_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void fade_darken_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void fade_darken_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int fade_darken_modes(magic_api * api, int which); Uint8 fade_darken_accepted_sizes(magic_api * api, int which, int mode); Uint8 fade_darken_default_size(magic_api * api, int which, int mode); -void fade_darken_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void fade_darken_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); int fade_darken_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) @@ -149,9 +140,9 @@ int fade_darken_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, sfx_filenames[i]); + for (i = 0; i < NUM_TOOLS; i++) + { + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, sfx_filenames[i]); snd_effects[i] = Mix_LoadWAV(fname); } @@ -174,8 +165,7 @@ SDL_Surface *fade_darken_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", - api->data_directory, icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, icon_filenames[which]); return (IMG_Load(fname)); } @@ -187,21 +177,18 @@ char *fade_darken_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (all the same): -int fade_darken_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fade_darken_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_COLOR_FILTERS; } // Return our description, localized: -char *fade_darken_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *fade_darken_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return strdup(gettext(tool_descriptions[which][mode - 1])); } -static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { Uint8 r, g, b; magic_api *api = (magic_api *) ptr; @@ -226,25 +213,36 @@ static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, api->rgbtohsv(r, g, b, &h, &s, &v); - if (which == TOOL_DESATURATE) { + if (which == TOOL_DESATURATE) + { s = (s * SAT_DESAT_RATIO_NUM) / SAT_DESAT_RATIO_DENOM; - } else if (which == TOOL_SATURATE) { - if (s > 0.1) { /* don't saturate things w/o undefined color! */ + } + else if (which == TOOL_SATURATE) + { + if (s > 0.1) + { /* don't saturate things w/o undefined color! */ s = (s * SAT_DESAT_RATIO_DENOM) / SAT_DESAT_RATIO_NUM; - if (s > 1.0) { + if (s > 1.0) + { s = 1.0; } } - } else if (which == TOOL_REMOVE) { + } + else if (which == TOOL_REMOVE) + { if (fabs(h - chosen_h) <= KEEP_REMOVE_HUE_THRESH - /* && fabs(s - chosen_s) <= KEEP_REMOVE_VALUE_THRESH */ -) { + /* && fabs(s - chosen_s) <= KEEP_REMOVE_VALUE_THRESH */ + ) + { s = 0.0; } - } else if (which == TOOL_KEEP) { + } + else if (which == TOOL_KEEP) + { if (fabs(h - chosen_h) > KEEP_REMOVE_HUE_THRESH - /* || fabs(s - chosen_s) > KEEP_REMOVE_VALUE_THRESH */ -) { + /* || fabs(s - chosen_s) > KEEP_REMOVE_VALUE_THRESH */ + ) + { s = 0.0; } } @@ -257,8 +255,7 @@ static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, // Callback that does the fade_darken color effect on a circle centered around x,y -static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; magic_api *api = (magic_api *) ptr; @@ -277,14 +274,12 @@ static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, // Ask Tux Paint to call our 'do_fade_darken_paint()' callback over a line void fade_darken_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) { SDL_LockSurface(last); SDL_LockSurface(canvas); - api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, - do_fade_darken_paint); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_fade_darken_paint); SDL_UnlockSurface(canvas); SDL_UnlockSurface(last); @@ -315,8 +310,7 @@ void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas, // Ask Tux Paint to call our 'do_fade_darken_paint()' callback at a single point, // or 'do_fade_darken()' on the entire image void fade_darken_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) fade_darken_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -342,8 +336,7 @@ void fade_darken_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -358,7 +351,8 @@ void fade_darken_shutdown(magic_api * api ATTRIBUTE_UNUSED) } void fade_darken_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { float tmp; @@ -366,8 +360,7 @@ void fade_darken_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf } // We don't use colors -int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { if (which == TOOL_REMOVE || which == TOOL_KEEP) return 1; @@ -376,27 +369,23 @@ int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED, } void fade_darken_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 fade_darken_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 fade_darken_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fade_darken_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } -Uint8 fade_darken_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 fade_darken_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { if (mode == MODE_PAINT) return 8; @@ -409,7 +398,9 @@ Uint8 fade_darken_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI return 4; } -void fade_darken_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 fade_darken_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) { fade_darken_radius = size * 4; } diff --git a/magic/src/fisheye.c b/magic/src/fisheye.c index 62afdd0c3..14b8c4f1b 100644 --- a/magic/src/fisheye.c +++ b/magic/src/fisheye.c @@ -49,39 +49,36 @@ int fisheye_get_group(magic_api * api, int which); char *fisheye_get_description(magic_api * api, int which, int mode); int fisheye_requires_colors(magic_api * api, int which); void fisheye_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 fisheye_shutdown(magic_api * api); -void fisheye_draw(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +void fisheye_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void fisheye_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 fisheye_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); -void fisheye_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void fisheye_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void fisheye_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void fisheye_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int fisheye_modes(magic_api * api, int which); Uint8 fisheye_accepted_sizes(magic_api * api, int which, int mode); Uint8 fisheye_default_size(magic_api * api, int which, int mode); -void fisheye_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void fisheye_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // Housekeeping functions void fisheye_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); Uint32 fisheye_api_version(void) { return (TP_MAGIC_API_VERSION); } -void fisheye_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) +void fisheye_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) { } @@ -89,8 +86,7 @@ int fisheye_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/fisheye.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/fisheye.ogg", api->data_directory); fisheye_snd = Mix_LoadWAV(fname); return (1); @@ -105,35 +101,27 @@ SDL_Surface *fisheye_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/fisheye.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/fisheye.png", api->data_directory); return (IMG_Load(fname)); } -char *fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Fisheye")); } -int fisheye_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fisheye_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } -char *fisheye_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *fisheye_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext_noop - ("Click on part of your picture to create a fisheye effect.")); + return strdup(gettext_noop("Click on part of your picture to create a fisheye effect.")); } -int fisheye_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fisheye_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -142,8 +130,7 @@ void fisheye_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) { } @@ -172,13 +159,11 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, oryg = SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius, fisheye_radius, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); output = SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius, fisheye_radius, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); rect.x = x - (fisheye_radius / 2); rect.y = y - (fisheye_radius / 2); @@ -191,8 +176,7 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, { temp_src = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, fisheye_radius, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); //let's take a smooth bar of scaled bitmap and copy it to temp //left side first @@ -205,10 +189,9 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, temp_dest = SDL_CreateRGBSurface(SDL_SWSURFACE, 1, fisheye_radius + 2 * i, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); - temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src + temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src temp_rect.x = 0; temp_rect.y = i; @@ -223,7 +206,7 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_BlitSurface(oryg, &rect, temp_src, NULL); //this bar is copied to temp_src //OK - temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src + temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src SDL_BlitSurface(temp_dest, &temp_rect, output, &rect); //let's copy it to output } @@ -233,14 +216,12 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, { temp_src = SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius, 1, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); temp_dest = SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius + 2 * i, 1, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); //upper side first rect.x = 0; @@ -274,9 +255,12 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, //let's blit an area surrounded by a circle - for (yy = y - (fisheye_radius / 2); yy < y + (fisheye_radius / 2); yy++) { - for (xx = x - (fisheye_radius / 2); xx < x + (fisheye_radius / 2); xx++) { - if (api->in_circle(xx - x, yy - y, (fisheye_radius / 2))) { + for (yy = y - (fisheye_radius / 2); yy < y + (fisheye_radius / 2); yy++) + { + for (xx = x - (fisheye_radius / 2); xx < x + (fisheye_radius / 2); xx++) + { + if (api->in_circle(xx - x, yy - y, (fisheye_radius / 2))) + { api->putpixel(canvas, xx, yy, api->getpixel(output, xx + (fisheye_radius / 2) - x, yy + (fisheye_radius / 2) - y)); } @@ -294,8 +278,7 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, } void fisheye_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(api, which, canvas, snapshot, ox, oy, x, y, 1, fisheye_draw); @@ -306,30 +289,26 @@ void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas, } void fisheye_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) { - last_x = -fisheye_radius; /* A value that will be beyond any clicked position */ + last_x = -fisheye_radius; /* A value that will be beyond any clicked position */ last_y = -fisheye_radius; fisheye_drag(api, which, canvas, last, x, y, x, y, update_rect); } void fisheye_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 fisheye_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 fisheye_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fisheye_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -337,15 +316,17 @@ int fisheye_modes(magic_api * api ATTRIBUTE_UNUSED, Uint8 fisheye_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return 5; // FIXME + return 5; // FIXME } Uint8 fisheye_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return 2; // FIXME + return 2; // FIXME } -void fisheye_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 fisheye_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) { fisheye_radius = size * 40; } diff --git a/magic/src/flower.c b/magic/src/flower.c index f96ecc13b..488f0aa86 100644 --- a/magic/src/flower.c +++ b/magic/src/flower.c @@ -59,8 +59,7 @@ static int flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y; static int flower_side_first; static int flower_side_decided; static SDL_Surface *flower_base_full = NULL, *flower_leaf_full = NULL, *flower_petals_full = NULL; -static SDL_Surface *flower_base = NULL, *flower_leaf = NULL, *flower_petals = NULL, - *flower_petals_colorized = NULL; +static SDL_Surface *flower_base = NULL, *flower_leaf = NULL, *flower_petals = NULL, *flower_petals_colorized = NULL; /* Local function prototypes: */ @@ -70,11 +69,9 @@ typedef struct } Point2D; static void flower_drawbase(magic_api * api, SDL_Surface * canvas); -static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, - int y); +static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, int y); static Point2D flower_PointOnCubicBezier(Point2D * cp, float t); -static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve); +static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve); Uint32 flower_api_version(void); int flower_init(magic_api * api, Uint32 disabled_features); int flower_get_tool_count(magic_api * api); @@ -82,37 +79,31 @@ SDL_Surface *flower_get_icon(magic_api * api, int which); char *flower_get_name(magic_api * api, int which); int flower_get_group(magic_api * api, int which); char *flower_get_description(magic_api * api, int which, int mode); -static void flower_predrag(magic_api * api, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y); +static void flower_predrag(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y); void flower_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); void flower_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void flower_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); -static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, - int y); +static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, int y); static void flower_drawbase(magic_api * api, SDL_Surface * canvas); static void flower_drawstalk(magic_api * api, SDL_Surface * canvas, - int top_x, int top_y, int minx, int maxx, - int bottom_x, int bottom_y, int final); + int top_x, int top_y, int minx, int maxx, int bottom_x, int bottom_y, int final); void flower_shutdown(magic_api * api); void flower_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int flower_requires_colors(magic_api * api, int which); static Point2D flower_PointOnCubicBezier(Point2D * cp, float t); -static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve); +static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve); static void flower_colorize_petals(magic_api * api); -void flower_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void flower_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void flower_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void flower_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int flower_modes(magic_api * api, int which); Uint8 flower_accepted_sizes(magic_api * api, int which, int mode); Uint8 flower_default_size(magic_api * api, int which, int mode); -void flower_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void flower_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -126,58 +117,59 @@ Uint32 flower_api_version(void) int flower_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - SDL_Surface * tmp_surf; + SDL_Surface *tmp_surf; int h; - snprintf(fname, sizeof(fname), "%ssounds/magic/flower_click.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/flower_click.ogg", api->data_directory); flower_click_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/flower_release.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/flower_release.ogg", api->data_directory); flower_release_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%simages/magic/flower_base.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/flower_base.png", api->data_directory); tmp_surf = IMG_Load(fname); - if (tmp_surf == NULL) { + if (tmp_surf == NULL) + { fprintf(stderr, "Cannot load %s", fname); - return(0); + return (0); } h = tmp_surf->h * MAX_WIDTH / tmp_surf->w; flower_base_full = api->scale(tmp_surf, MAX_WIDTH, h, 1); - if (flower_base_full == NULL) { + if (flower_base_full == NULL) + { fprintf(stderr, "Cannot scale %s", fname); - return(0); + return (0); } - snprintf(fname, sizeof(fname), "%simages/magic/flower_leaf.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/flower_leaf.png", api->data_directory); tmp_surf = IMG_Load(fname); - if (tmp_surf == NULL) { + if (tmp_surf == NULL) + { fprintf(stderr, "Cannot load %s", fname); - return(0); + return (0); } /* N.B.: Leaf is 1/2 as wide as base & petals */ h = tmp_surf->h * (MAX_WIDTH / 2) / tmp_surf->w; flower_leaf_full = api->scale(tmp_surf, MAX_WIDTH / 2, h, 1); - if (flower_leaf_full == NULL) { + if (flower_leaf_full == NULL) + { fprintf(stderr, "Cannot scale %s", fname); - return(0); + return (0); } - snprintf(fname, sizeof(fname), "%simages/magic/flower_petals.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/flower_petals.png", api->data_directory); tmp_surf = IMG_Load(fname); - if (tmp_surf == NULL) { + if (tmp_surf == NULL) + { fprintf(stderr, "Cannot load %s", fname); - return(0); + return (0); } h = tmp_surf->h * MAX_WIDTH / tmp_surf->w; flower_petals_full = api->scale(tmp_surf, MAX_WIDTH, h, 1); - if (flower_petals_full == NULL) { + if (flower_petals_full == NULL) + { fprintf(stderr, "Cannot scale %s", fname); - return(0); + return (0); } flower_cur_size = DEFAULT_SIZE; @@ -197,41 +189,33 @@ SDL_Surface *flower_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/flower.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/flower.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *flower_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *flower_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Flower"))); } // Return our groups: -int flower_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int flower_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } // Return our descriptions, localized: -char *flower_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *flower_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag to draw a flower stalk. Let go to finish the flower."))); + return (strdup(gettext_noop("Click and drag to draw a flower stalk. Let go to finish the flower."))); } // Affect the canvas on drag: static void flower_predrag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last ATTRIBUTE_UNUSED, int ox, - int oy, int x, int y) + SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y) { if (x < flower_min_x) flower_min_x = x; @@ -265,8 +249,7 @@ static void flower_predrag(magic_api * api ATTRIBUTE_UNUSED, } void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, - int x, int y, SDL_Rect * update_rect) + SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect) { flower_predrag(api, canvas, last, ox, oy, x, y); @@ -279,8 +262,7 @@ void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED, /* Draw the base and the stalk (low-quality) for now: */ flower_drawstalk(api, canvas, - x, y, flower_min_x, flower_max_x, flower_bottom_x, - flower_bottom_y, !(api->button_down())); + x, y, flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y, !(api->button_down())); flower_drawbase(api, canvas); @@ -292,8 +274,7 @@ void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED, // Affect the canvas on click: void flower_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) { flower_min_x = x; flower_max_x = x; @@ -310,8 +291,7 @@ void flower_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on release: void flower_release(magic_api * api, int which 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) { /* Don't let flower be too low compared to base: */ @@ -331,8 +311,7 @@ void flower_release(magic_api * api, int which ATTRIBUTE_UNUSED, /* Draw high-quality stalk, and flower: */ - flower_drawstalk(api, canvas, x, y, flower_min_x, flower_max_x, - flower_bottom_x, flower_bottom_y, 1); + flower_drawstalk(api, canvas, x, y, flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y, 1); flower_drawflower(api, canvas, x, y); @@ -348,12 +327,11 @@ void flower_release(magic_api * api, int which ATTRIBUTE_UNUSED, } -static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED, - SDL_Surface * canvas, int x, int y) +static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas, int x, int y) { SDL_Rect dest; - if (flower_petals_colorized == NULL) // Abort! + if (flower_petals_colorized == NULL) // Abort! return; dest.x = x - (flower_petals_colorized->w / 2); @@ -362,12 +340,11 @@ static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED, SDL_BlitSurface(flower_petals_colorized, NULL, canvas, &dest); } -static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED, - SDL_Surface * canvas) +static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas) { SDL_Rect dest; - if (flower_base == NULL) // Abort! + if (flower_base == NULL) // Abort! return; dest.x = flower_bottom_x - (flower_base->w / 2); @@ -378,8 +355,7 @@ static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED, static void flower_drawstalk(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas, int top_x, int top_y, - int minx, int maxx, int bottom_x, int bottom_y, - int final) + int minx, int maxx, int bottom_x, int bottom_y, int final) { Point2D control_points[4]; Point2D *curve; @@ -389,7 +365,7 @@ static void flower_drawstalk(magic_api * api ATTRIBUTE_UNUSED, int xx, yy, side; - if (flower_leaf == NULL) // Abort! + if (flower_leaf == NULL) // Abort! return; /* Compute a nice bezier curve for the stalk, based on the @@ -585,7 +561,8 @@ void flower_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void flower_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { flower_r = r; flower_g = g; @@ -595,8 +572,7 @@ void flower_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * } // Use colors: -int flower_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int flower_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -651,8 +627,7 @@ static Point2D flower_PointOnCubicBezier(Point2D * cp, float t) */ -static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve) +static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve) { float dt; int i; @@ -673,14 +648,12 @@ static void flower_colorize_petals(magic_api * api) if (flower_petals_colorized != NULL) SDL_FreeSurface(flower_petals_colorized); - if (flower_petals == NULL) // Abort! + if (flower_petals == NULL) // Abort! return; /* Create a surface to render into: */ - amask = - ~(flower_petals->format->Rmask | flower_petals->format-> - Gmask | flower_petals->format->Bmask); + amask = ~(flower_petals->format->Rmask | flower_petals->format->Gmask | flower_petals->format->Bmask); flower_petals_colorized = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -688,8 +661,7 @@ static void flower_colorize_petals(magic_api * api) flower_petals->h, flower_petals->format->BitsPerPixel, flower_petals->format->Rmask, - flower_petals->format->Gmask, - flower_petals->format->Bmask, amask); + flower_petals->format->Gmask, flower_petals->format->Bmask, amask); /* Render the new petals: */ @@ -700,19 +672,14 @@ static void flower_colorize_petals(magic_api * api) { for (x = 0; x < flower_petals->w; x++) { - SDL_GetRGBA(api->getpixel(flower_petals, x, y), flower_petals->format, - &r, &g, &b, &a); + SDL_GetRGBA(api->getpixel(flower_petals, x, y), flower_petals->format, &r, &g, &b, &a); api->putpixel(flower_petals_colorized, x, y, - SDL_MapRGBA(flower_petals_colorized->format, flower_r, - flower_g, flower_b, a)); + SDL_MapRGBA(flower_petals_colorized->format, flower_r, flower_g, flower_b, a)); - if (api->in_circle - ((x - flower_petals->w / 2), (y - flower_petals->h / 2), (flower_petals->w / 4))) + if (api->in_circle((x - flower_petals->w / 2), (y - flower_petals->h / 2), (flower_petals->w / 4))) { - api->putpixel(flower_petals_colorized, x, y, - SDL_MapRGBA(flower_petals_colorized->format, 0xFF, 0xFF, - 0x00, a)); + api->putpixel(flower_petals_colorized, x, y, SDL_MapRGBA(flower_petals_colorized->format, 0xFF, 0xFF, 0x00, a)); } } } @@ -722,14 +689,12 @@ static void flower_colorize_petals(magic_api * api) } void flower_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 flower_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) { } @@ -748,7 +713,9 @@ Uint8 flower_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return DEFAULT_SIZE; } -void flower_set_size(magic_api * api, 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 flower_set_size(magic_api * api, 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) { int scale, width, height; diff --git a/magic/src/foam.c b/magic/src/foam.c index 0f2a21438..a9eb3f95b 100644 --- a/magic/src/foam.c +++ b/magic/src/foam.c @@ -45,23 +45,17 @@ Uint32 foam_api_version(void); int foam_init(magic_api * api, Uint32 disabled_features); char *foam_get_description(magic_api * api, int which, int mode); void foam_release(magic_api * api, int which, - SDL_Surface * canvas, SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); -void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * update_rect); + SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); +void foam_release_worker(SDL_Surface * canvas, SDL_Surface * last, SDL_Rect * update_rect); void foam_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); void foam_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); SDL_Surface *foam_get_icon(magic_api * api, int which); -char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED); -int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED); -void foam_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void foam_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED); +int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED); +void foam_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void foam_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void foam_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void foam_shutdown(magic_api * api); @@ -70,7 +64,8 @@ int foam_modes(magic_api * api, int which); int foam_requires_colors(magic_api * api, int which); Uint8 foam_accepted_sizes(magic_api * api, int which, int mode); Uint8 foam_default_size(magic_api * api, int which, int mode); -void foam_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void foam_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); #define FOAM_PROP 8 #define FOAM_RADIUS 3 @@ -87,26 +82,16 @@ int foam_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) char fname[1024]; SDL_Surface *foam_data; - snprintf(fname, sizeof(fname), "%ssounds/magic/foam.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/foam.ogg", api->data_directory); foam_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%simages/magic/foam_data.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/foam_data.png", api->data_directory); foam_data = IMG_Load(fname); - foam_7 = - api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4, - ((api->canvas_h / FOAM_PROP) * 4) / 4, 1); - foam_5 = - api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4, - ((api->canvas_h / FOAM_PROP) * 3) / 4, 1); - foam_3 = - api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4, - ((api->canvas_h / FOAM_PROP) * 2) / 4, 1); - foam_1 = - api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4, - ((api->canvas_h / FOAM_PROP) * 1) / 4, 1); + foam_7 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4, ((api->canvas_h / FOAM_PROP) * 4) / 4, 1); + foam_5 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4, ((api->canvas_h / FOAM_PROP) * 3) / 4, 1); + foam_3 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4, ((api->canvas_h / FOAM_PROP) * 2) / 4, 1); + foam_1 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4, ((api->canvas_h / FOAM_PROP) * 1) / 4, 1); SDL_FreeSurface(foam_data); @@ -124,41 +109,33 @@ SDL_Surface *foam_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/foam.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/foam.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Foam"))); } // Return our groups -int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *foam_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *foam_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag the mouse to cover an area with foamy bubbles."))); + return (strdup(gettext_noop("Click and drag the mouse to cover an area with foamy bubbles."))); } // Do the effect: static void do_foam(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy, nx, ny; @@ -185,10 +162,9 @@ static void do_foam(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void foam_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_foam); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_foam); foam_release_worker(canvas, last, update_rect); // foam_release(api, which, canvas, last, x, y, update_rect); @@ -220,8 +196,7 @@ void foam_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void foam_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * last, int x ATTRIBUTE_UNUSED, - int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) + SDL_Surface * last, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) { int i; @@ -230,8 +205,8 @@ void foam_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, foam_mask_w = canvas->w / FOAM_PROP; foam_mask_h = canvas->h / FOAM_PROP; - foam_mask = (int *) malloc(sizeof(int) * (foam_mask_w * foam_mask_h)); - foam_mask_tmp = (int *) malloc(sizeof(int) * (foam_mask_w * foam_mask_h)); + foam_mask = (int *)malloc(sizeof(int) * (foam_mask_w * foam_mask_h)); + foam_mask_tmp = (int *)malloc(sizeof(int) * (foam_mask_w * foam_mask_h)); } for (i = 0; i < foam_mask_w * foam_mask_h; i++) @@ -265,14 +240,13 @@ static int foam_mask_test(int r, int x, int y) // Affect the canvas on release: void foam_release(magic_api * api ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * last, int x ATTRIBUTE_UNUSED, - int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) + SDL_Surface * last, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) { api->stopsound(); foam_release_worker(canvas, last, update_rect); } -void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * update_rect) +void foam_release_worker(SDL_Surface * canvas, SDL_Surface * last, SDL_Rect * update_rect) { int xx, yy; int changes, max_iters; @@ -282,8 +256,7 @@ void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * upd SDL_BlitSurface(last, NULL, canvas, NULL); - memcpy(foam_mask_tmp, foam_mask, - (sizeof(int) * (foam_mask_w * foam_mask_h))); + memcpy(foam_mask_tmp, foam_mask, (sizeof(int) * (foam_mask_w * foam_mask_h))); max_iters = 2; @@ -441,8 +414,7 @@ void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * upd } } - memcpy(foam_mask, foam_mask_tmp, - (sizeof(int) * (foam_mask_w * foam_mask_h))); + memcpy(foam_mask, foam_mask_tmp, (sizeof(int) * (foam_mask_w * foam_mask_h))); update_rect->x = 0; @@ -472,7 +444,8 @@ void foam_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void foam_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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { foam_r = r; foam_g = g; @@ -480,21 +453,18 @@ void foam_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED } // Use colors: -int foam_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int foam_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; /* FIXME: Would be nice to tint the bubbles */ } void foam_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 foam_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) { } @@ -514,6 +484,8 @@ Uint8 foam_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 0; } -void foam_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 foam_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) { } diff --git a/magic/src/fold.c b/magic/src/fold.c index 45dd3ff0f..a3fa790a8 100644 --- a/magic/src/fold.c +++ b/magic/src/fold.c @@ -30,21 +30,15 @@ SDL_Surface *fold_surface_src, *fold_surface_dst; void fold_draw(magic_api * api, int which, - SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -static void fold_erase(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +static void fold_erase(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void translate_coords(SDL_Surface * canvas, int angle); SDL_Surface *rotate(magic_api * api, SDL_Surface * canvas, int angle); void fold_draw(magic_api * api, int which, - SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -static void fold_print_line(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void fold_print_dark_line(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, - int rotation); + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +static void fold_print_line(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void fold_print_dark_line(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, int rotation); Uint32 fold_api_version(void); void fold_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); @@ -56,30 +50,25 @@ int fold_get_group(magic_api * api, int which); char *fold_get_description(magic_api * api, int which, int mode); int fold_requires_colors(magic_api * api, int which); void fold_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 fold_shutdown(magic_api * api); void fold_click(magic_api * ptr, 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 fold_preview(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); int fold_modes(magic_api * api, int which); // Housekeeping functions void fold_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 fold_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void fold_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); inline Uint8 fold_what_corner(int x, int y, SDL_Surface * canvas); -void fold_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void fold_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); Uint8 fold_accepted_sizes(magic_api * api, int which, int mode); Uint8 fold_default_size(magic_api * api, int which, int mode); -void fold_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void fold_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 fold_api_version(void) { @@ -87,7 +76,8 @@ Uint32 fold_api_version(void) } void fold_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 * 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 fold_r = r; @@ -99,8 +89,7 @@ int fold_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/fold.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/fold.wav", api->data_directory); fold_snd = Mix_LoadWAV(fname); return (1); @@ -111,48 +100,37 @@ int fold_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) return 1; } -SDL_Surface *fold_get_icon(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +SDL_Surface *fold_get_icon(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/fold.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/fold.png", api->data_directory); return (IMG_Load(fname)); } -char *fold_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *fold_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (gettext_noop("Fold")); } -int fold_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fold_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } -char *fold_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *fold_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext_noop - ("Choose a background color and click to turn the corner of the page over.")); + return strdup(gettext_noop("Choose a background color and click to turn the corner of the page over.")); } -int fold_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fold_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } //selected color will be a "backpage" color -static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * temp, int x, - int y) +static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * temp, int x, int y) { magic_api *api = (magic_api *) ptr; Uint8 r, g, b, a; @@ -162,14 +140,11 @@ static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED, max(r - 160 + fold_shadow_value * 4, 0), max(g - 160 + fold_shadow_value * 4, - 0), - max(b - 160 + fold_shadow_value * 4, - 0), a)); + 0), max(b - 160 + fold_shadow_value * 4, 0), a)); } void fold_draw(magic_api * api, int which, - SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { float right_step_x, right_step_y, left_step_x, left_step_y; float dist_x, dist_y; @@ -180,17 +155,16 @@ void fold_draw(magic_api * api, int which, temp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); SDL_BlitSurface(canvas, 0, temp, 0); - right_step_x = (float) (x - left_arm_x) / (float) (left_arm_x - fold_ox); - right_step_y = (float) (y - left_arm_y) / (float) (left_arm_x - fold_ox); - left_step_x = (float) (x - right_arm_x) / (float) (right_arm_y - fold_oy); - left_step_y = (float) (y - right_arm_y) / (float) (right_arm_y - fold_oy); + right_step_x = (float)(x - left_arm_x) / (float)(left_arm_x - fold_ox); + right_step_y = (float)(y - left_arm_y) / (float)(left_arm_x - fold_ox); + left_step_x = (float)(x - right_arm_x) / (float)(right_arm_y - fold_oy); + left_step_y = (float)(y - right_arm_y) / (float)(right_arm_y - fold_oy); - left_y = (float) right_arm_y / left_arm_x * (left_arm_x - canvas->w); - right_x = (float) left_arm_x / right_arm_y * (right_arm_y - canvas->h); + left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w); + right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h); for (w = 0; w < canvas->w; w += 0.5) { @@ -198,8 +172,7 @@ void fold_draw(magic_api * api, int which, { dist_x = right_step_x * w + left_step_x * h; dist_y = right_step_y * w + left_step_y * h; - api->putpixel(canvas, x - dist_x, y - dist_y, - api->getpixel(temp, w, h)); + api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h)); } } @@ -208,71 +181,58 @@ void fold_draw(magic_api * api, int which, if (left_arm_x > canvas->w) { for (h = 0; h <= right_arm_y; h++) - api->line((void *) api, which, canvas, snapshot, canvas->w, left_y - h, - -1, right_arm_y - h, 1, fold_erase); + api->line((void *)api, which, canvas, snapshot, canvas->w, left_y - h, -1, right_arm_y - h, 1, fold_erase); } else if (right_arm_y > canvas->h) { for (w = 0; w <= left_arm_x; w++) - api->line((void *) api, which, canvas, snapshot, left_arm_x - w, 0, - right_x - w, canvas->h + 1, 1, fold_erase); + api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, right_x - w, canvas->h + 1, 1, fold_erase); } else for (w = 0; w <= min(left_arm_x, right_arm_y); w++) // The -1 values are because api->line - api->line((void *) api, which, canvas, snapshot, left_arm_x - w, 0, -1, - right_arm_y - w, 1, fold_erase); + api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, -1, right_arm_y - w, 1, fold_erase); SDL_BlitSurface(canvas, 0, temp, 0); // Shadows if (left_arm_x > canvas->w) { - for (fold_shadow_value = 0; fold_shadow_value < 40; - fold_shadow_value += 1) - api->line((void *) api, which, canvas, temp, canvas->w, - left_y - fold_shadow_value, 0, - right_arm_y - fold_shadow_value, 1, fold_shadow); + for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1) + api->line((void *)api, which, canvas, temp, canvas->w, + left_y - fold_shadow_value, 0, right_arm_y - fold_shadow_value, 1, fold_shadow); } else if (right_arm_y > canvas->h) { - for (fold_shadow_value = 0; fold_shadow_value < 40; - fold_shadow_value += 1) - api->line((void *) api, which, canvas, temp, - left_arm_x - fold_shadow_value, 0, - right_x - fold_shadow_value, canvas->h, 1, fold_shadow); + for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1) + api->line((void *)api, which, canvas, temp, + left_arm_x - fold_shadow_value, 0, right_x - fold_shadow_value, canvas->h, 1, fold_shadow); } else - for (fold_shadow_value = 0; fold_shadow_value < 40; - fold_shadow_value += 1) - api->line((void *) api, which, canvas, temp, - left_arm_x - fold_shadow_value, 0, 0, - right_arm_y - fold_shadow_value, 1, fold_shadow); + for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1) + api->line((void *)api, which, canvas, temp, + left_arm_x - fold_shadow_value, 0, 0, right_arm_y - fold_shadow_value, 1, fold_shadow); SDL_BlitSurface(canvas, 0, temp, 0); for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1) { - if (fold_shadow_value * left_step_x > x - || fold_shadow_value * right_step_y > y) + if (fold_shadow_value * left_step_x > x || fold_shadow_value * right_step_y > y) break; dist_x = fold_shadow_value * (right_step_x + left_step_x); dist_y = fold_shadow_value * (right_step_y + left_step_y); - api->line((void *) api, which, canvas, temp, + api->line((void *)api, which, canvas, temp, left_arm_x + fold_shadow_value * right_step_x, fold_shadow_value * right_step_y, - fold_shadow_value * left_step_x, - right_arm_y + fold_shadow_value * left_step_y, 1, fold_shadow); + fold_shadow_value * left_step_x, right_arm_y + fold_shadow_value * left_step_y, 1, fold_shadow); } - api->line((void *) api, which, canvas, snapshot, x, y, right_arm_x, - right_arm_y, 1, fold_print_line); - api->line((void *) api, which, canvas, snapshot, x, y, left_arm_x, - left_arm_y, 1, fold_print_line); - api->line((void *) api, which, canvas, snapshot, left_arm_x, left_arm_y, + api->line((void *)api, which, canvas, snapshot, x, y, right_arm_x, right_arm_y, 1, fold_print_line); + api->line((void *)api, which, canvas, snapshot, x, y, left_arm_x, left_arm_y, 1, fold_print_line); + api->line((void *)api, which, canvas, snapshot, left_arm_x, left_arm_y, right_arm_x, right_arm_y, 1, fold_print_dark_line); } @@ -287,14 +247,12 @@ SDL_Surface *rotate(magic_api * api, SDL_Surface * canvas, int angle) temp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); else temp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->h, canvas->w, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); switch (angle) { @@ -361,8 +319,7 @@ void translate_coords(SDL_Surface * canvas, int angle) } } -void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, - int rotation) +void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, int rotation) { switch (rotation) { @@ -382,8 +339,7 @@ void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, } void fold_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 a, b; SDL_Surface *temp, *temp2; @@ -467,8 +423,7 @@ inline Uint8 fold_what_corner(int x, int y, SDL_Surface * canvas) static void fold_print_line(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, - int y) + SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -476,9 +431,7 @@ static void fold_print_line(void *ptr, int which ATTRIBUTE_UNUSED, } static void fold_print_dark_line(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, - int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -486,18 +439,15 @@ static void fold_print_dark_line(void *ptr, int which ATTRIBUTE_UNUSED, } static void fold_erase(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, fold_r, fold_g, fold_b)); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, fold_r, fold_g, fold_b)); } void fold_click(magic_api * ptr, 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) { magic_api *api = (magic_api *) ptr; @@ -527,8 +477,7 @@ void fold_click(magic_api * ptr, int which, int mode ATTRIBUTE_UNUSED, void fold_preview(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) + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int middle_point_x; int middle_point_y; @@ -543,67 +492,49 @@ void fold_preview(magic_api * api, int which, SDL_Surface * canvas, switch (corner) { case 1: //Right Upper - right_arm_x = - fold_ox - (fold_ox - middle_point_x) - - middle_point_y * middle_point_y / (fold_ox - middle_point_x); + right_arm_x = fold_ox - (fold_ox - middle_point_x) - middle_point_y * middle_point_y / (fold_ox - middle_point_x); right_arm_y = fold_oy; left_arm_x = fold_ox; left_arm_y = fold_oy - (fold_oy - middle_point_y) - (fold_ox - - middle_point_x) * (fold_ox - - middle_point_x) - / (fold_oy - middle_point_y); + middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y); break; case 2: //LU right_arm_x = fold_ox; - right_arm_y = - middle_point_y + middle_point_x * middle_point_x / middle_point_y; + right_arm_y = middle_point_y + middle_point_x * middle_point_x / middle_point_y; - left_arm_x = - middle_point_x + middle_point_y * middle_point_y / middle_point_x; + left_arm_x = middle_point_x + middle_point_y * middle_point_y / middle_point_x; left_arm_y = fold_oy; break; case 3: //LL - right_arm_x = - middle_point_x + (fold_oy - middle_point_y) * (fold_oy - - middle_point_y) / - middle_point_x; + right_arm_x = middle_point_x + (fold_oy - middle_point_y) * (fold_oy - middle_point_y) / middle_point_x; right_arm_y = fold_oy; left_arm_x = fold_ox; left_arm_y = fold_oy - (fold_oy - middle_point_y) - (fold_ox - - middle_point_x) * (fold_ox - - middle_point_x) - / (fold_oy - middle_point_y); + middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y); break; case 4: //RL right_arm_x = fold_ox; right_arm_y = fold_oy - (fold_oy - middle_point_y) - (fold_ox - - middle_point_x) * (fold_ox - - middle_point_x) - / (fold_oy - middle_point_y); + middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y); left_arm_x = fold_ox - (fold_ox - middle_point_x) - (fold_oy - - middle_point_y) * (fold_oy - - middle_point_y) - / (fold_ox - middle_point_x); + middle_point_y) * (fold_oy - middle_point_y) / (fold_ox - middle_point_x); left_arm_y = fold_oy; break; } - api->line((void *) api, which, canvas, snapshot, x, y, right_arm_x, - right_arm_y, 1, fold_print_line); - api->line((void *) api, which, canvas, snapshot, x, y, left_arm_x, - left_arm_y, 1, fold_print_line); - api->line((void *) api, which, canvas, snapshot, left_arm_x, left_arm_y, - right_arm_x, right_arm_y, 1, fold_print_line); + api->line((void *)api, which, canvas, snapshot, x, y, right_arm_x, right_arm_y, 1, fold_print_line); + api->line((void *)api, which, canvas, snapshot, x, y, left_arm_x, left_arm_y, 1, fold_print_line); + api->line((void *)api, which, canvas, snapshot, left_arm_x, left_arm_y, right_arm_x, right_arm_y, 1, fold_print_line); update_rect->x = update_rect->y = 0; update_rect->w = canvas->w; @@ -611,8 +542,7 @@ void fold_preview(magic_api * api, int which, SDL_Surface * canvas, } void fold_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) { // Avoid division by zero when calculating the preview x = clamp(2, x, canvas->w - 2); @@ -621,14 +551,12 @@ void fold_drag(magic_api * api, int which, SDL_Surface * canvas, } void fold_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 fold_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) { } @@ -648,6 +576,8 @@ Uint8 fold_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 0; } -void fold_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 fold_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) { } diff --git a/magic/src/fretwork.c b/magic/src/fretwork.c index 53029b468..6daa8c86f 100644 --- a/magic/src/fretwork.c +++ b/magic/src/fretwork.c @@ -49,8 +49,7 @@ static unsigned int fretwork_update_rectangle_width; //the width of the updat static unsigned int fretwork_update_rectangle_height; //the height of the update_rectangle static SDL_Rect modification_rect; static SDL_Surface *canvas_backup; -static SDL_Surface *fretwork_one_back, *fretwork_three_back, - *fretwork_four_back, *fretwork_corner_back; +static SDL_Surface *fretwork_one_back, *fretwork_three_back, *fretwork_four_back, *fretwork_corner_back; // Housekeeping functions @@ -59,8 +58,7 @@ Uint32 fretwork_api_version(void); int fretwork_modes(magic_api * api, int which); void fretwork_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); -static void fretwork_colorize(magic_api * api, SDL_Surface * dest, - SDL_Surface * src); +static void fretwork_colorize(magic_api * api, SDL_Surface * dest, SDL_Surface * src); int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED); int fretwork_get_tool_count(magic_api * api); SDL_Surface *fretwork_get_icon(magic_api * api, int which); @@ -69,32 +67,26 @@ int fretwork_get_group(magic_api * api, int which); char *fretwork_get_description(magic_api * api, int which, int mode); int fretwork_requires_colors(magic_api * api, int which); void fretwork_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 fretwork_shutdown(magic_api * api); -void fretwork_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * snapshot); -void fretwork_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * snapshot); +void fretwork_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot); +void fretwork_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot); + #define POINT_TYPE typeof(((SDL_Rect *)NULL)->x) -inline void fretwork_extract_coords_from_segment(unsigned int segment, - POINT_TYPE * x, - POINT_TYPE * y); +inline void fretwork_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y); void fretwork_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 fretwork_drag(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int ox, int oy, int x, int y, - SDL_Rect * update_rect); -static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); inline unsigned int fretwork_get_segment(int x, int y); Uint8 fretwork_accepted_sizes(magic_api * api, int which, int mode); Uint8 fretwork_default_size(magic_api * api, int which, int mode); -void fretwork_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void fretwork_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); SDL_Surface *fretwork_one, *fretwork_three, *fretwork_four, *fretwork_corner; @@ -104,14 +96,14 @@ Uint32 fretwork_api_version(void) return (TP_MAGIC_API_VERSION); } -int fretwork_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fretwork_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } void fretwork_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { fretwork_r = r; fretwork_g = g; @@ -123,8 +115,7 @@ void fretwork_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface } /* Adapted from flower.c */ -static void fretwork_colorize(magic_api * api, SDL_Surface * dest, - SDL_Surface * src) +static void fretwork_colorize(magic_api * api, SDL_Surface * dest, SDL_Surface * src) { int x, y; Uint8 r, g, b, a; @@ -138,9 +129,7 @@ static void fretwork_colorize(magic_api * api, SDL_Surface * dest, { SDL_GetRGBA(api->getpixel(src, x, y), src->format, &r, &g, &b, &a); - api->putpixel(dest, x, y, - SDL_MapRGBA(dest->format, fretwork_r, fretwork_g, - fretwork_b, a)); + api->putpixel(dest, x, y, SDL_MapRGBA(dest->format, fretwork_r, fretwork_g, fretwork_b, a)); } } @@ -154,19 +143,15 @@ int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) char fname[1024]; Uint8 i; //is always < 4, so Uint8 seems to be a good idea - fretwork_images = (char **) malloc(sizeof(char *) * 4); + fretwork_images = (char **)malloc(sizeof(char *) * 4); for (i = 0; i < 4; i++) - fretwork_images[i] = (char *) malloc(sizeof(char) * 1024); + fretwork_images[i] = (char *)malloc(sizeof(char) * 1024); - snprintf(fretwork_images[0], 1024 * sizeof(char), - "%simages/magic/fretwork_one.png", api->data_directory); - snprintf(fretwork_images[1], 1024 * sizeof(char), - "%simages/magic/fretwork_three.png", api->data_directory); - snprintf(fretwork_images[2], 1024 * sizeof(char), - "%simages/magic/fretwork_four.png", api->data_directory); - snprintf(fretwork_images[3], 1024 * sizeof(char), - "%simages/magic/fretwork_corner.png", api->data_directory); + snprintf(fretwork_images[0], 1024 * sizeof(char), "%simages/magic/fretwork_one.png", api->data_directory); + snprintf(fretwork_images[1], 1024 * sizeof(char), "%simages/magic/fretwork_three.png", api->data_directory); + snprintf(fretwork_images[2], 1024 * sizeof(char), "%simages/magic/fretwork_four.png", api->data_directory); + snprintf(fretwork_images[3], 1024 * sizeof(char), "%simages/magic/fretwork_corner.png", api->data_directory); fretwork_one = IMG_Load(fretwork_images[0]); fretwork_three = IMG_Load(fretwork_images[1]); @@ -180,8 +165,7 @@ int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) img_w = fretwork_one->w; img_h = fretwork_one->h; - snprintf(fname, sizeof(fname), "%ssounds/magic/fretwork.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/fretwork.ogg", api->data_directory); fretwork_snd = Mix_LoadWAV(fname); return (1); @@ -196,38 +180,30 @@ SDL_Surface *fretwork_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/fretwork.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/fretwork.png", api->data_directory); return (IMG_Load(fname)); } -int fretwork_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fretwork_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } -char *fretwork_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *fretwork_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Fretwork")); } -char *fretwork_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *fretwork_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return - strdup(gettext_noop("Click and drag to draw repetitive patterns.")); + return strdup(gettext_noop("Click and drag to draw repetitive patterns.")); else - return - strdup(gettext_noop - ("Click to surround your picture with repetitive patterns.")); + return strdup(gettext_noop("Click to surround your picture with repetitive patterns.")); } -int fretwork_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int fretwork_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -236,8 +212,7 @@ void fretwork_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) { } @@ -266,16 +241,14 @@ void fretwork_shutdown(magic_api * api ATTRIBUTE_UNUSED) void fretwork_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * snapshot ATTRIBUTE_UNUSED) + SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED) { //we've to compute the quantity of segments in each direction canvas_backup = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); SDL_BlitSurface(canvas, NULL, canvas_backup, NULL); fretwork_segments_x = fretwork_math_ceil(canvas->w, img_w); @@ -287,8 +260,7 @@ void fretwork_switchin(magic_api * api ATTRIBUTE_UNUSED, void fretwork_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * snapshot ATTRIBUTE_UNUSED) + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED) { free(fretwork_status_of_segments); fretwork_status_of_segments = NULL; @@ -301,7 +273,7 @@ inline int fretwork_math_ceil(int x, int y) { int temp; - temp = (int) x / y; + temp = (int)x / y; if (x % y) return temp + 1; else @@ -320,12 +292,10 @@ inline unsigned int fretwork_get_segment(int x, int y) return (yy - 1) * fretwork_segments_x + xx; } -inline void fretwork_extract_coords_from_segment(unsigned int segment, - POINT_TYPE * x, - POINT_TYPE * y) +inline void fretwork_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y) { *x = ((segment % fretwork_segments_x) - 1) * img_w; //useful to set update_rect as small as possible - *y = (int) (segment / fretwork_segments_x) * img_h; + *y = (int)(segment / fretwork_segments_x) * img_h; } /* static void fretwork_flip(void * ptr, SDL_Surface * dest, SDL_Surface * src) */ @@ -339,20 +309,17 @@ inline void fretwork_extract_coords_from_segment(unsigned int segment, /* api->putpixel(dest, x, y, api->getpixel(src, x, src->h-y)); */ /* } */ -static void fretwork_flip_flop(void *ptr, SDL_Surface * dest, - SDL_Surface * src) +static void fretwork_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src) { magic_api *api = (magic_api *) ptr; POINT_TYPE x, y; for (x = 0; x < dest->w; x++) for (y = 0; y < dest->h; y++) - api->putpixel(dest, dest->w - 1 - x, dest->h - 1 - y, - api->getpixel(src, x, y)); + api->putpixel(dest, dest->w - 1 - x, dest->h - 1 - y, api->getpixel(src, x, y)); } -static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, - _Bool direction) +static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, _Bool direction) //src and dest must have same size { magic_api *api = (magic_api *) ptr; @@ -375,8 +342,7 @@ static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, void fretwork_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) { int left_x, right_x, top_y, bottom_y; @@ -388,29 +354,26 @@ void fretwork_click(magic_api * api, int which, int mode, } else { - if (fretwork_full_runs <= - min(fretwork_segments_x, fretwork_segments_y) / 2) + if (fretwork_full_runs <= min(fretwork_segments_x, fretwork_segments_y) / 2) { left_x = img_w * fretwork_full_runs; right_x = img_w * fretwork_segments_x - img_w * fretwork_full_runs; top_y = img_h * fretwork_full_runs; - bottom_y = - img_h * fretwork_segments_y - img_h * (fretwork_full_runs - 1); + bottom_y = img_h * fretwork_segments_y - img_h * (fretwork_full_runs - 1); //left line - api->line((void *) api, which, canvas, snapshot, left_x, top_y, left_x, + api->line((void *)api, which, canvas, snapshot, left_x, top_y, left_x, bottom_y, img_w / 2, fretwork_draw_wrapper); //top line - api->line((void *) api, which, canvas, snapshot, left_x, top_y, right_x, - top_y, img_w / 2, fretwork_draw_wrapper); + api->line((void *)api, which, canvas, snapshot, left_x, top_y, right_x, top_y, img_w / 2, fretwork_draw_wrapper); //bottom line - api->line((void *) api, which, canvas, snapshot, left_x, bottom_y, + api->line((void *)api, which, canvas, snapshot, left_x, bottom_y, right_x, bottom_y, img_w / 2, fretwork_draw_wrapper); //right line - api->line((void *) api, which, canvas, snapshot, right_x, top_y, + api->line((void *)api, which, canvas, snapshot, right_x, top_y, right_x, bottom_y, img_w / 2, fretwork_draw_wrapper); fretwork_full_runs += 1; @@ -427,8 +390,7 @@ static Uint8 fretwork_select_image(Uint16 segment) int take_up, take_down; int val_up, val_down, val_left, val_right; int from_top = 0, from_bottom = 0, from_left = 0, from_right = 0; - int from_top_right = 0, from_top_left = 0, from_bottom_right = - 0, from_bottom_left = 0; + int from_top_right = 0, from_top_left = 0, from_bottom_right = 0, from_bottom_left = 0; int TOP = 0, BOTTOM = 0, LEFT = 0, RIGHT = 0; //Checking from were we come... @@ -445,26 +407,22 @@ static Uint8 fretwork_select_image(Uint16 segment) // Very very few cases will reach this, segments are joining by the corner // We need to add a new segment to join by side, adding clockwise - else if (segment == - fretwork_segment_modified_last + fretwork_segments_x + 1) + else if (segment == fretwork_segment_modified_last + fretwork_segments_x + 1) { from_top_left = 1; fretwork_segment_to_add = segment - fretwork_segments_x; } - else if (segment == - fretwork_segment_modified_last + fretwork_segments_x - 1) + else if (segment == fretwork_segment_modified_last + fretwork_segments_x - 1) { from_top_right = 1; fretwork_segment_to_add = segment + 1; } - else if (segment == - fretwork_segment_modified_last - fretwork_segments_x - 1) + else if (segment == fretwork_segment_modified_last - fretwork_segments_x - 1) { from_bottom_right = 1; fretwork_segment_to_add = segment + fretwork_segments_x; } - else if (segment == - fretwork_segment_modified_last - fretwork_segments_x + 1) + else if (segment == fretwork_segment_modified_last - fretwork_segments_x + 1) { from_bottom_left = 1; fretwork_segment_to_add = segment - 1; @@ -478,7 +436,7 @@ static Uint8 fretwork_select_image(Uint16 segment) val_up = fretwork_status_of_segments[take_up]; take_down = segment + fretwork_segments_x; - if (take_down > (signed) (fretwork_segments_x * fretwork_segments_y)) + if (take_down > (signed)(fretwork_segments_x * fretwork_segments_y)) val_down = SEG_NONE; else val_down = fretwork_status_of_segments[take_down]; @@ -536,8 +494,7 @@ static Uint8 fretwork_select_image(Uint16 segment) static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, - int y ATTRIBUTE_UNUSED, unsigned int segment) + SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y ATTRIBUTE_UNUSED, unsigned int segment) { magic_api *api = (magic_api *) ptr; SDL_Surface *result, *temp; @@ -547,8 +504,7 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED, use_temp = 0; if ((segment < 1) | (segment > fretwork_segments_x * fretwork_segments_y)) return; - fretwork_extract_coords_from_segment(segment, &modification_rect.x, - &modification_rect.y); + fretwork_extract_coords_from_segment(segment, &modification_rect.x, &modification_rect.y); modification_rect.h = img_w; modification_rect.w = img_h; @@ -563,17 +519,13 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_CreateRGBSurface(SDL_SWSURFACE, img_w, img_h, fretwork_one->format->BitsPerPixel, fretwork_one->format->Rmask, - fretwork_one->format->Gmask, - fretwork_one->format->Bmask, - fretwork_one->format->Amask); + fretwork_one->format->Gmask, fretwork_one->format->Bmask, fretwork_one->format->Amask); temp = SDL_CreateRGBSurface(SDL_SWSURFACE, img_w, img_h, fretwork_one->format->BitsPerPixel, fretwork_one->format->Rmask, - fretwork_one->format->Gmask, - fretwork_one->format->Bmask, - fretwork_one->format->Amask); + fretwork_one->format->Gmask, fretwork_one->format->Bmask, fretwork_one->format->Amask); SDL_BlitSurface(canvas_backup, &modification_rect, result, NULL); @@ -645,32 +597,25 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED, } -static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { fretwork_segment_modified = fretwork_get_segment(x, y); - fretwork_draw((void *) ptr, which, canvas, last, x, y, - fretwork_segment_modified); + fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified); if (fretwork_segment_modified_last > 0) { - fretwork_draw((void *) ptr, which, canvas, last, x, y, - fretwork_segment_modified_last); - fretwork_extract_coords_from_segment(fretwork_segment_start_rectangle, - &modification_rect.x, - &modification_rect.y); + fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified_last); + fretwork_extract_coords_from_segment(fretwork_segment_start_rectangle, &modification_rect.x, &modification_rect.y); modification_rect.w = fretwork_update_rectangle_width * img_w; modification_rect.h = fretwork_update_rectangle_height * img_h; } if (fretwork_segment_to_add > 0) { - fretwork_draw((void *) ptr, which, canvas, last, x, y, - fretwork_segment_to_add); - fretwork_draw((void *) ptr, which, canvas, last, x, y, - fretwork_segment_modified_last); + fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_to_add); + fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified_last); fretwork_segment_to_add = 0; } @@ -678,17 +623,14 @@ static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, } void fretwork_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 * canvas, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect) { int start_x, end_x, start_y, end_y, segment_start, segment_end, w, h; if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w) - && (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0) - && ((signed) ox > 0) && ((signed) oy > 0)) + && (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0)) { - api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, - fretwork_draw_wrapper); + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, fretwork_draw_wrapper); // This should be improved, maybe passed to fretwork_draw() start_x = min(ox, x); end_x = max(ox, x); @@ -698,9 +640,9 @@ void fretwork_drag(magic_api * api, int which, segment_end = fretwork_get_segment(end_x + img_w, end_y + img_h); x = ((segment_start % fretwork_segments_x) - 1) * img_w; - y = (int) (segment_start / fretwork_segments_x) * img_h; + y = (int)(segment_start / fretwork_segments_x) * img_h; w = ((segment_end % fretwork_segments_x) - 1) * img_w - x + img_w; - h = (int) (segment_end / fretwork_segments_x) * img_h - y + img_h; + h = (int)(segment_end / fretwork_segments_x) * img_h - y + img_h; update_rect->x = x; update_rect->y = y; @@ -719,6 +661,8 @@ Uint8 fretwork_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT return 0; } -void fretwork_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 fretwork_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) { } diff --git a/magic/src/glasstile.c b/magic/src/glasstile.c index 347dd2fc3..f8b569409 100644 --- a/magic/src/glasstile.c +++ b/magic/src/glasstile.c @@ -48,29 +48,24 @@ SDL_Surface *glasstile_get_icon(magic_api * api, int which); char *glasstile_get_name(magic_api * api, int which); int glasstile_get_group(magic_api * api, int which); char *glasstile_get_description(magic_api * api, int which, int mode); -static void do_glasstile(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_glasstile(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void glasstile_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); void glasstile_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 glasstile_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void glasstile_shutdown(magic_api * api); void glasstile_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int glasstile_requires_colors(magic_api * api, int which); -void glasstile_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void glasstile_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void glasstile_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void glasstile_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int glasstile_modes(magic_api * api, int which); Uint8 glasstile_accepted_sizes(magic_api * api, int which, int mode); Uint8 glasstile_default_size(magic_api * api, int which, int mode); -void glasstile_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void glasstile_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 glasstile_api_version(void) @@ -87,8 +82,7 @@ int glasstile_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/glasstile.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/glasstile.ogg", api->data_directory); glasstile_snd = Mix_LoadWAV(fname); glasstile_hit = NULL; @@ -108,45 +102,35 @@ SDL_Surface *glasstile_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/glasstile.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/glasstile.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *glasstile_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *glasstile_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Glass Tile"))); } // Return our groups -int glasstile_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int glasstile_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *glasstile_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *glasstile_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return (strdup - (gettext_noop - ("Click and drag the mouse to put glass tile over your picture."))); + return (strdup(gettext_noop("Click and drag the mouse to put glass tile over your picture."))); else - return (strdup - (gettext_noop - ("Click to cover your entire picture in glass tiles."))); + return (strdup(gettext_noop("Click to cover your entire picture in glass tiles."))); } // Do the effect: -static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, - int y) +static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy, xl, xr, yt, yb; @@ -180,14 +164,10 @@ static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED, { for (xx = -GT_SIZE; xx < GT_SIZE; xx = xx + 2) { - SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r1, &g1, - &b1); - SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy), last->format, &r2, - &g2, &b2); - SDL_GetRGB(api->getpixel(last, x + xx, y + yy + 1), last->format, &r3, - &g3, &b3); - SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy + 1), last->format, - &r4, &g4, &b4); + SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r1, &g1, &b1); + SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy), last->format, &r2, &g2, &b2); + SDL_GetRGB(api->getpixel(last, x + xx, y + yy + 1), last->format, &r3, &g3, &b3); + SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy + 1), last->format, &r4, &g4, &b4); r = (r1 + r2 + r3 + r4) >> 2; g = (g1 + g2 + g3 + g4) >> 2; @@ -233,10 +213,9 @@ static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void glasstile_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_glasstile); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_glasstile); update_rect->x = 0; update_rect->y = 0; @@ -269,8 +248,7 @@ void glasstile_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void glasstile_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) { int xx, yy; @@ -279,10 +257,10 @@ void glasstile_click(magic_api * api, int which, int mode, glasstile_hit_ysize = (canvas->h / GT_SIZE) + 1; glasstile_hit_xsize = (canvas->w / GT_SIZE) + 1; - glasstile_hit = (int * *) malloc(sizeof(int *) * glasstile_hit_ysize); + glasstile_hit = (int * *)malloc(sizeof(int *) * glasstile_hit_ysize); for (yy = 0; yy < glasstile_hit_ysize; yy++) - glasstile_hit[yy] = (int *) malloc(sizeof(int) * glasstile_hit_xsize); + glasstile_hit[yy] = (int *)malloc(sizeof(int) * glasstile_hit_xsize); } for (yy = 0; yy < glasstile_hit_ysize; yy++) @@ -311,8 +289,7 @@ void glasstile_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -336,33 +313,30 @@ void glasstile_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void glasstile_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) +void glasstile_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) { } // Use colors: -int glasstile_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int glasstile_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void glasstile_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 glasstile_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 glasstile_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int glasstile_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } @@ -379,6 +353,8 @@ Uint8 glasstile_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU return 0; } -void glasstile_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 glasstile_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) { } diff --git a/magic/src/googlyeyes.c b/magic/src/googlyeyes.c index 97c155c1f..757e6cec7 100644 --- a/magic/src/googlyeyes.c +++ b/magic/src/googlyeyes.c @@ -19,12 +19,14 @@ #define NUM_SIZES 2 int sizes[NUM_SIZES] = { 100, 50 }; -char * googlyeyes_descr[NUM_SIZES] = { + +char *googlyeyes_descr[NUM_SIZES] = { gettext_noop("Click to place a large googly eye, then drag and release to make it look that direction."), gettext_noop("Click to place a small googly eye, then drag and release to make it look that direction."), }; -char * img_filenames[NUM_SIZES] = { - "googlyeyes.png", // Also used with magic sizes + +char *img_filenames[NUM_SIZES] = { + "googlyeyes.png", // Also used with magic sizes "googlyeyes-sm.png" }; @@ -34,9 +36,9 @@ int googlyeyes_limited = 0; int googlyeyes_sizes; int googlyeyes_size; Mix_Chunk *snd_effect = NULL; -SDL_Surface * * googlyeyes_img_bkgd = NULL; -SDL_Surface * * googlyeyes_img_pupil = NULL; -SDL_Surface * * googlyeyes_img_reflection = NULL; +SDL_Surface **googlyeyes_img_bkgd = NULL; +SDL_Surface **googlyeyes_img_pupil = NULL; +SDL_Surface **googlyeyes_img_reflection = NULL; int eye_x, eye_y; Uint32 googlyeyes_api_version(void); @@ -48,27 +50,22 @@ int googlyeyes_get_group(magic_api * api, int which); char *googlyeyes_get_description(magic_api * api, int which, int mode); int googlyeyes_requires_colors(magic_api * api, int which); int googlyeyes_modes(magic_api * api, int which); -Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); +Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED); Uint8 googlyeyes_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); void googlyeyes_shutdown(magic_api * api); void googlyeyes_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 googlyeyes_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void googlyeyes_set_size(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last, - Uint8 sz, SDL_Rect * update_rect); + SDL_Surface * canvas, SDL_Surface * last, Uint8 sz, SDL_Rect * update_rect); void googlyeyes_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 googlyeyes_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -void googlyeyes_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void googlyeyes_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +void googlyeyes_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void googlyeyes_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); Uint32 googlyeyes_api_version(void) @@ -84,30 +81,32 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features) googlyeyes_limited = (disabled_features & MAGIC_FEATURE_SIZE); /* Load sound effect */ - snprintf(fname, sizeof(fname), "%ssounds/magic/googlyeyes.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/googlyeyes.ogg", api->data_directory); snd_effect = Mix_LoadWAV(fname); /* Init the images */ - if (googlyeyes_limited) { + if (googlyeyes_limited) + { googlyeyes_sizes = NUM_SIZES; - } else { + } + else + { googlyeyes_sizes = NUM_SCALEABLE_SIZES; } - googlyeyes_img_bkgd = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); - googlyeyes_img_pupil = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); - googlyeyes_img_reflection = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); + googlyeyes_img_bkgd = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); + googlyeyes_img_pupil = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); + googlyeyes_img_reflection = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes); - for (i = 0; i < googlyeyes_sizes; i++) { + for (i = 0; i < googlyeyes_sizes; i++) + { googlyeyes_img_bkgd[i] = NULL; googlyeyes_img_pupil[i] = NULL; googlyeyes_img_reflection[i] = NULL; } /* Load the base images (100% scale) */ - snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-bkgd.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-bkgd.png", api->data_directory); googlyeyes_img_bkgd[0] = IMG_Load(fname); if (googlyeyes_img_bkgd[0] == NULL) { @@ -115,8 +114,7 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features) return 0; } - snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-pupil.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-pupil.png", api->data_directory); googlyeyes_img_pupil[0] = IMG_Load(fname); if (googlyeyes_img_pupil[0] == NULL) { @@ -124,8 +122,7 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features) return 0; } - snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-reflection.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-reflection.png", api->data_directory); googlyeyes_img_reflection[0] = IMG_Load(fname); if (googlyeyes_img_reflection[0] == NULL) { @@ -134,43 +131,47 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features) } /* Create the scaled versions */ - for (i = 1; i < googlyeyes_sizes; i++) { + for (i = 1; i < googlyeyes_sizes; i++) + { int size; - if (googlyeyes_limited) { + if (googlyeyes_limited) + { size = sizes[i]; - } else { + } + else + { size = (100 * (googlyeyes_sizes - i)) / googlyeyes_sizes; } googlyeyes_img_bkgd[i] = api->scale(googlyeyes_img_bkgd[0], (googlyeyes_img_bkgd[0]->w * size) / 100, - (googlyeyes_img_bkgd[0]->h * size) / 100, - 1); + (googlyeyes_img_bkgd[0]->h * size) / 100, 1); - if (googlyeyes_img_bkgd[i] == NULL) { + if (googlyeyes_img_bkgd[i] == NULL) + { fprintf(stderr, "Cannot scale bkgd to %d%%", size); - return(1); + return (1); } googlyeyes_img_pupil[i] = api->scale(googlyeyes_img_pupil[0], - (googlyeyes_img_pupil[0]->w * size) / 100, - (googlyeyes_img_pupil[0]->h * size) / 100, - 1); + (googlyeyes_img_pupil[0]->w * size) / 100, + (googlyeyes_img_pupil[0]->h * size) / 100, 1); - if (googlyeyes_img_pupil[i] == NULL) { + if (googlyeyes_img_pupil[i] == NULL) + { fprintf(stderr, "Cannot scale pupil to %d%%", size); - return(1); + return (1); } googlyeyes_img_reflection[i] = api->scale(googlyeyes_img_reflection[0], - (googlyeyes_img_reflection[0]->w * size) / 100, - (googlyeyes_img_reflection[0]->h * size) / 100, - 1); + (googlyeyes_img_reflection[0]->w * size) / 100, + (googlyeyes_img_reflection[0]->h * size) / 100, 1); - if (googlyeyes_img_reflection[i] == NULL) { + if (googlyeyes_img_reflection[i] == NULL) + { fprintf(stderr, "Cannot scale reflection to %d%%", size); - return(1); + return (1); } } @@ -179,9 +180,12 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features) int googlyeyes_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) { - if (googlyeyes_limited) { + if (googlyeyes_limited) + { return (NUM_SIZES); - } else { + } + else + { return 1; } } @@ -191,52 +195,52 @@ SDL_Surface *googlyeyes_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", - api->data_directory, img_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, img_filenames[which]); return (IMG_Load(fname)); } -char *googlyeyes_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *googlyeyes_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext("Googly Eyes")); } -int googlyeyes_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int googlyeyes_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } char *googlyeyes_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - if (googlyeyes_limited) { + if (googlyeyes_limited) + { return strdup(gettext(googlyeyes_descr[which])); - } else { + } + else + { return strdup(gettext_noop("Click to place a googly eye, then drag and release to make it look that direction.")); } } -int googlyeyes_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int googlyeyes_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -int googlyeyes_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int googlyeyes_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT; } Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - if (googlyeyes_limited) { + if (googlyeyes_limited) + { return 1; - } else { + } + else + { return NUM_SCALEABLE_SIZES; } } @@ -253,7 +257,8 @@ void googlyeyes_shutdown(magic_api * api ATTRIBUTE_UNUSED) if (snd_effect != NULL) Mix_FreeChunk(snd_effect); - for (i = 0; i < googlyeyes_sizes; i++) { + for (i = 0; i < googlyeyes_sizes; i++) + { if (googlyeyes_img_bkgd[i] != NULL) SDL_FreeSurface(googlyeyes_img_bkgd[i]); @@ -272,17 +277,19 @@ void googlyeyes_shutdown(magic_api * api ATTRIBUTE_UNUSED) void googlyeyes_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) { int img; eye_x = x; eye_y = y; - if (googlyeyes_limited) { + if (googlyeyes_limited) + { img = which; - } else { + } + else + { img = googlyeyes_size - 1; } @@ -300,16 +307,19 @@ googlyeyes_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) + SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { SDL_Rect dest; int max_radius; int img; - if (googlyeyes_limited) { + if (googlyeyes_limited) + { img = which; - } else { + } + else + { img = googlyeyes_size - 1; } @@ -327,7 +337,8 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva /* 2. Draw the pupil */ max_radius = ((googlyeyes_img_bkgd[img]->w - googlyeyes_img_pupil[img]->w) / 2); - if (sqrt(((x - eye_x) * (x - eye_x)) + ((y - eye_y) * (y - eye_y))) > max_radius) { + if (sqrt(((x - eye_x) * (x - eye_x)) + ((y - eye_y) * (y - eye_y))) > max_radius) + { /* If drag position would place pupil outside the circular bounds * of the background, put it on the edge, "looking towards" (pointing at) * the mouse. */ @@ -335,8 +346,8 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva * https://github.com/freedesktop/xorg-xeyes/blob/master/Eyes.c) */ double dx, dy, angle; - dx = (double) (x - eye_x); - dy = (double) (y - eye_y); + dx = (double)(x - eye_x); + dy = (double)(y - eye_y); angle = atan2(dy, dx); x = eye_x + (cos(angle) * max_radius); @@ -360,15 +371,16 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva void googlyeyes_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) + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED, + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } -void googlyeyes_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) +void googlyeyes_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) { } @@ -381,14 +393,11 @@ void googlyeyes_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U } void googlyeyes_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 googlyeyes_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) { } diff --git a/magic/src/grass.c b/magic/src/grass.c index 317f22d17..528c1bc72 100644 --- a/magic/src/grass.c +++ b/magic/src/grass.c @@ -49,8 +49,7 @@ char *grass_get_name(magic_api * api, int which); int grass_get_group(magic_api * api, int which); char *grass_get_description(magic_api * api, int which, int mode); void grass_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); void grass_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void grass_release(magic_api * api, int which, SDL_Surface * canvas, @@ -59,29 +58,25 @@ void grass_shutdown(magic_api * api); void grass_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int grass_requires_colors(magic_api * api, int which); -static void do_grass(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_grass(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); static int log2int(int x); -void grass_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void grass_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void grass_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void grass_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int grass_modes(magic_api * api, int which); Uint8 grass_accepted_sizes(magic_api * api, int which, int mode); Uint8 grass_default_size(magic_api * api, int which, int mode); -void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: int grass_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav", api->data_directory); grass_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png", api->data_directory); img_grass = IMG_Load(fname); return (1); @@ -105,43 +100,35 @@ SDL_Surface *grass_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/grass.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/grass.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Grass"))); } // Return our groups: -int grass_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int grass_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag to draw grass. Don’t forget the dirt!"))); + return (strdup(gettext_noop("Click and drag to draw grass. Don’t forget the dirt!"))); } // Affect the canvas on drag: void grass_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, 4, do_grass); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 4, do_grass); if (ox > x) { @@ -168,8 +155,7 @@ void grass_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void grass_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) { grass_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -178,8 +164,7 @@ void grass_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -191,8 +176,9 @@ void grass_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void grass_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 grass_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) { grass_r = r; grass_g = g; @@ -200,15 +186,13 @@ void grass_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE } // Use colors: -int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -221,12 +205,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED, if (!api->button_down()) bucket = 0; - bucket += (3.5 + (rand() / (double) RAND_MAX)) * 7.0; + bucket += (3.5 + (rand() / (double)RAND_MAX)) * 7.0; while (bucket >= 0) { - int rank = - log2int(((double) y / canvas->h) * - (0.99 + (rand() / (double) RAND_MAX)) * 64); + int rank = log2int(((double)y / canvas->h) * (0.99 + (rand() / (double)RAND_MAX)) * 64); int ah = 1 << rank; bucket -= ah; @@ -236,12 +218,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED, src.h = ah; dest.x = x - 32; - dest.y = y - 30 + (int) ((rand() / (double) RAND_MAX) * 30); + dest.y = y - 30 + (int)((rand() / (double)RAND_MAX) * 30); - tmp_red = - api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double) RAND_MAX); - tmp_green = - api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double) RAND_MAX); + tmp_red = api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double)RAND_MAX); + tmp_green = api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double)RAND_MAX); tmp_blue = api->sRGB_to_linear(grass_b) * 2.0 + api->sRGB_to_linear(17); for (yy = 0; yy < ah; yy++) @@ -250,8 +230,7 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED, { double rd, gd, bd; - SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y), - img_grass->format, &r, &g, &b, &a); + SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y), img_grass->format, &r, &g, &b, &a); rd = api->sRGB_to_linear(r) * 8.0 + tmp_red; rd = rd * (a / 255.0) / 11.0; @@ -260,21 +239,13 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED, bd = api->sRGB_to_linear(b) * 8.0 + tmp_blue; bd = bd * (a / 255.0) / 11.0; - SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y), - canvas->format, &r, &g, &b); + SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y), canvas->format, &r, &g, &b); - r = - api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) + - rd); - g = - api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) + - gd); - b = - api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) + - bd); + r = api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) + rd); + g = api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) + gd); + b = api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) + bd); - api->putpixel(canvas, xx + dest.x, yy + dest.y, - SDL_MapRGB(canvas->format, r, g, b)); + api->putpixel(canvas, xx + dest.x, yy + dest.y, SDL_MapRGB(canvas->format, r, g, b)); } } } @@ -297,14 +268,12 @@ static int log2int(int x) } void grass_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 grass_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) { } @@ -325,6 +294,8 @@ Uint8 grass_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 0; } -void grass_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 grass_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) { } diff --git a/magic/src/halftone.c b/magic/src/halftone.c index df0c8f71d..544978d7f 100644 --- a/magic/src/halftone.c +++ b/magic/src/halftone.c @@ -59,10 +59,8 @@ static SDL_Surface *canvas_backup, *square; /* Function Prototypes: */ void halftone_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 halftone_line_callback(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void halftone_line_callback(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); Uint32 halftone_api_version(void); int halftone_init(magic_api * api, Uint32 disabled_features); int halftone_get_tool_count(magic_api * api); @@ -74,21 +72,18 @@ int halftone_requires_colors(magic_api * api, int which); int halftone_modes(magic_api * api, int which); void halftone_shutdown(magic_api * api); void halftone_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 halftone_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); void halftone_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); -void halftone_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void halftone_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void halftone_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void halftone_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[]); Uint8 halftone_accepted_sizes(magic_api * api, int which, int mode); Uint8 halftone_default_size(magic_api * api, int which, int mode); -void halftone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void halftone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -107,8 +102,7 @@ int halftone_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, snd_filenames[i]); snd_effect[i] = Mix_LoadWAV(fname); } @@ -126,8 +120,7 @@ SDL_Surface *halftone_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, icon_filenames[which]); return (IMG_Load(fname)); } @@ -148,8 +141,7 @@ int halftone_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) return groups[which]; } -char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { const char *our_desc_english; const char *our_desc_localized; @@ -160,14 +152,12 @@ char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, return (strdup(our_desc_localized)); } -int halftone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int halftone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -int halftone_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int halftone_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } @@ -189,8 +179,7 @@ void halftone_shutdown(magic_api * api ATTRIBUTE_UNUSED) } void halftone_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) { int full_x, full_y; @@ -216,11 +205,9 @@ void halftone_click(magic_api * api, int which, int mode, } void halftone_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, 4, - halftone_line_callback); + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 4, halftone_line_callback); if (ox > x) { @@ -278,21 +265,20 @@ void halftone_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) { } -void halftone_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) +void halftone_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) { } void halftone_line_callback(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) { Uint8 r, g, b, or, og, ob; Uint32 total_r, total_g, total_b; @@ -323,8 +309,7 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, { for (yyy = -(GRID_SIZE / 2); yyy < (GRID_SIZE / 2); yyy++) { - SDL_GetRGB(api->getpixel(canvas_backup, x + xxx, y + yyy), - canvas_backup->format, &r, &g, &b); + SDL_GetRGB(api->getpixel(canvas_backup, x + xxx, y + yyy), canvas_backup->format, &r, &g, &b); total_r += r; total_g += g; total_b += b; @@ -367,12 +352,10 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, /* Additively blend with whatever we have in the 'square' buffer (which starts as white) (since the target is RGB, we use `min()`) */ - SDL_GetRGB(api->getpixel(square, sqx, sqy), square->format, &or, - &og, &ob); + SDL_GetRGB(api->getpixel(square, sqx, sqy), square->format, &or, &og, &ob); pixel = SDL_MapRGB(square->format, min((Uint8) (r * 2.0), or), - min((Uint8) (g * 2.0), og), min((Uint8) (b * 2.0), - ob)); + min((Uint8) (g * 2.0), og), min((Uint8) (b * 2.0), ob)); api->putpixel(square, sqx, sqy, pixel); } } @@ -388,16 +371,14 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, SDL_BlitSurface(square, NULL, canvas, &dest); } -void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) +void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { if (canvas_backup == NULL) { canvas_backup = SDL_CreateRGBSurface(SDL_SWSURFACE, api->canvas_w, api->canvas_h, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); } if (square == NULL) @@ -405,16 +386,14 @@ void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, square = SDL_CreateRGBSurface(SDL_SWSURFACE, GRID_SIZE, GRID_SIZE, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, canvas->format->Amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); } SDL_BlitSurface(canvas, NULL, canvas_backup, NULL); } void halftone_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) { } @@ -436,9 +415,9 @@ void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[]) } else { - c = 1.0 - (((float) r) / 255.0); - m = 1.0 - (((float) g) / 255.0); - y = 1.0 - (((float) b) / 255.0); + c = 1.0 - (((float)r) / 255.0); + m = 1.0 - (((float)g) / 255.0); + y = 1.0 - (((float)b) / 255.0); mincmy = min(c, min(m, y)); c = (c - mincmy) / (1.0 - mincmy); @@ -456,14 +435,16 @@ void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[]) Uint8 halftone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return 0; // No size support at this time + return 0; // No size support at this time } Uint8 halftone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return 0; // No size support at this time + return 0; // No size support at this time } -void halftone_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 halftone_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) { } diff --git a/magic/src/kaleidox.c b/magic/src/kaleidox.c index 90f283e57..99f3532c8 100644 --- a/magic/src/kaleidox.c +++ b/magic/src/kaleidox.c @@ -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) { } diff --git a/magic/src/kalidescope.c b/magic/src/kalidescope.c index ad5f43925..1cb8b57d4 100644 --- a/magic/src/kalidescope.c +++ b/magic/src/kalidescope.c @@ -70,17 +70,13 @@ SDL_Surface *kalidescope_get_icon(magic_api * api, int which); char *kalidescope_get_name(magic_api * api, int which); int kalidescope_get_group(magic_api * api, int which); char *kalidescope_get_description(magic_api * api, int which, int mode); -static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void kalidescope_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); void kalidescope_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 kalidescope_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void kalidescope_shutdown(magic_api * api); int kalidescope_requires_colors(magic_api * api, int which); Uint8 kalidescope_accepted_sizes(magic_api * api, int which, int mode); @@ -88,12 +84,9 @@ Uint8 kalidescope_default_size(magic_api * api, int which, int mode); void kalidescope_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void kalidescope_set_size(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last, - Uint8 sz, SDL_Rect * update_rect); -void kalidescope_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void kalidescope_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * canvas, SDL_Surface * last, Uint8 sz, SDL_Rect * update_rect); +void kalidescope_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void kalidescope_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int kalidescope_modes(magic_api * api, int which); Uint32 kalidescope_api_version(void) @@ -105,8 +98,7 @@ int kalidescope_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/kaleidoscope.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/kaleidoscope.ogg", api->data_directory); kalidescope_snd = Mix_LoadWAV(fname); return (1); @@ -122,8 +114,7 @@ SDL_Surface *kalidescope_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - kal_icon_names[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, kal_icon_names[which]); return (IMG_Load(fname)); } @@ -154,16 +145,14 @@ char *kalidescope_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (all the same): -int kalidescope_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int kalidescope_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PATTERN_PAINTING; } // Return our descriptions, localized: -char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { if (which == KAL_LR) { @@ -179,21 +168,15 @@ char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, } else if (which == KAL_PATTERN) { - return (strdup - (gettext_noop - ("Click and drag the mouse to draw a pattern across the picture."))); + return (strdup(gettext_noop("Click and drag the mouse to draw a pattern across the picture."))); } else if (which == KAL_TILES) { - return (strdup - (gettext_noop - ("Click and drag the mouse to draw a pattern that is symmetric across the picture."))); + return (strdup(gettext_noop("Click and drag the mouse to draw a pattern that is symmetric across the picture."))); } else { /* KAL_BOTH */ - return (strdup - (gettext_noop - ("Click and drag the mouse to draw with symmetric brushes (a kaleidoscope)."))); + return (strdup(gettext_noop("Click and drag the mouse to draw with symmetric brushes (a kaleidoscope)."))); } } @@ -207,8 +190,7 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, int i, j; Uint32 colr; - colr = - SDL_MapRGB(canvas->format, kalidescope_r, kalidescope_g, kalidescope_b); + colr = SDL_MapRGB(canvas->format, kalidescope_r, kalidescope_g, kalidescope_b); for (yy = -kalidescope_sz; yy < kalidescope_sz; yy++) { @@ -224,8 +206,7 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, if (which == KAL_BOTH) { - api->putpixel(canvas, canvas->w - 1 - x + xx, - canvas->h - 1 - y + yy, colr); + api->putpixel(canvas, canvas->w - 1 - x + xx, canvas->h - 1 - y + yy, colr); } } if (which == KAL_UD || which == KAL_BOTH) @@ -237,11 +218,9 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, for (i = 0; i <= canvas->w; i += square_size) for (j = 0; j <= canvas->h; j += square_size) { - api->putpixel(canvas, i + xx + x % square_size, - j + yy + y % square_size, colr); + api->putpixel(canvas, i + xx + x % square_size, j + yy + y % square_size, colr); if (which == KAL_TILES) - api->putpixel(canvas, i + yy + y % square_size, - j + xx + x % square_size, colr); + api->putpixel(canvas, i + yy + y % square_size, j + xx + x % square_size, colr); } } } @@ -251,11 +230,9 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void kalidescope_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_kalidescope); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_kalidescope); update_rect->x = 0; update_rect->y = 0; @@ -267,8 +244,7 @@ void kalidescope_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void kalidescope_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) { kalidescope_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -277,8 +253,7 @@ void kalidescope_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void kalidescope_release(magic_api * api, 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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { api->stopsound(); } @@ -291,15 +266,15 @@ void kalidescope_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Use colors: -int kalidescope_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int kalidescope_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } // Record the color from Tux Paint: -void kalidescope_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 kalidescope_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) { kalidescope_r = r; kalidescope_g = g; @@ -313,8 +288,7 @@ Uint8 kalidescope_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, return KAL_MAX_SIZE; } -Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return KAL_DEF_SIZE; } @@ -329,21 +303,16 @@ void kalidescope_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ void kalidescope_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 kalidescope_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 kalidescope_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int kalidescope_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } diff --git a/magic/src/light.c b/magic/src/light.c index 19330bf7d..2963b9a93 100644 --- a/magic/src/light.c +++ b/magic/src/light.c @@ -50,11 +50,9 @@ SDL_Surface *light_get_icon(magic_api * api, int which); char *light_get_name(magic_api * api, int which); int light_get_group(magic_api * api, int which); char *light_get_description(magic_api * api, int which, int mode); -static void do_light(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_light(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void light_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); void light_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void light_release(magic_api * api, int which, SDL_Surface * canvas, @@ -63,14 +61,13 @@ void light_shutdown(magic_api * api); void light_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int light_requires_colors(magic_api * api, int which); -void light_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void light_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void light_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void light_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int light_modes(magic_api * api, int which); Uint8 light_accepted_sizes(magic_api * api, int which, int mode); Uint8 light_default_size(magic_api * api, int which, int mode); -void light_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void light_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 light_api_version(void) @@ -84,12 +81,10 @@ int light_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/light1.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/light1.ogg", api->data_directory); light1_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/light2.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/light2.ogg", api->data_directory); light2_snd = Mix_LoadWAV(fname); return (1); @@ -106,41 +101,33 @@ SDL_Surface *light_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/light.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/light.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *light_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *light_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Light"))); } // Return our groups: -int light_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int light_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *light_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *light_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag to draw a beam of light on your picture."))); + return (strdup(gettext_noop("Click and drag to draw a beam of light on your picture."))); } // Do the effect: static void do_light(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -159,11 +146,11 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED, SDL_GetRGB(pix, canvas->format, &r, &g, &b); - adj = (((float) light_radius - 0.01) - sqrt(abs(xx * yy))) / (16.0 * (float) light_radius); + adj = (((float)light_radius - 0.01) - sqrt(abs(xx * yy))) / (16.0 * (float)light_radius); api->rgbtohsv(r, g, b, &h, &s, &v); - v = min((float) 1.0, v + adj); + v = min((float)1.0, v + adj); if (light_h == -1 && h == -1) { @@ -192,8 +179,7 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED, api->hsvtorgb(new_h, new_s, new_v, &r, &g, &b); - api->putpixel(canvas, x + xx, y + yy, - SDL_MapRGB(canvas->format, r, g, b)); + api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b)); } } } @@ -201,10 +187,9 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void light_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_light); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_light); if (ox > x) { @@ -231,8 +216,7 @@ void light_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void light_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) { light_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -240,8 +224,7 @@ void light_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on release: void light_release(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + int x, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { api->playsound(light2_snd, (x * 255) / canvas->w, 255); } @@ -257,27 +240,25 @@ void light_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void light_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { api->rgbtohsv(r, g, b, &light_h, &light_s, &light_v); } // Use colors: -int light_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int light_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } void light_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 light_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) { } @@ -297,7 +278,9 @@ Uint8 light_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 2; } -void light_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 light_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) { light_radius = size * 4; } diff --git a/magic/src/lightning.c b/magic/src/lightning.c index 99beab0c7..0adfee750 100644 --- a/magic/src/lightning.c +++ b/magic/src/lightning.c @@ -31,28 +31,22 @@ int lightning_requires_colors(magic_api * api, int which); int lightning_modes(magic_api * api, int which); void lightning_shutdown(magic_api * api); void lightning_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 lightning_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void lightning_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 lightning_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void lightning_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void lightning_draw_bolt(void *ptr, SDL_Surface * canvas, - SDL_Surface * snapshot, float sx, float sy, - float angle, float len, int thickness); + SDL_Surface * snapshot, float sx, float sy, float angle, float len, int thickness); void lightning_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -void lightning_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void lightning_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +void lightning_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void lightning_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); Uint8 lightning_accepted_sizes(magic_api * api, int which, int mode); Uint8 lightning_default_size(magic_api * api, int which, int mode); -void lightning_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void lightning_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 lightning_api_version(void) @@ -64,8 +58,7 @@ int lightning_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/lightning.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/lightning.ogg", api->data_directory); snd_effect = Mix_LoadWAV(fname); return (1); @@ -81,41 +74,32 @@ SDL_Surface *lightning_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/lightning.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/lightning.png", api->data_directory); return (IMG_Load(fname)); } -char *lightning_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *lightning_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext("Lightning")); } -int lightning_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int lightning_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } -char *lightning_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *lightning_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext - ("Click, drag, and release to draw a lightning bolt between two points.")); + return strdup(gettext("Click, drag, and release to draw a lightning bolt between two points.")); } -int lightning_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int lightning_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } -int lightning_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int lightning_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT; } @@ -129,8 +113,7 @@ void lightning_shutdown(magic_api * api ATTRIBUTE_UNUSED) void lightning_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) { sx = x; sy = y; @@ -154,15 +137,13 @@ lightning_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_BlitSurface(snapshot, update_rect, canvas, update_rect); - api->line((void *) api, which, canvas, snapshot, sx, sy, x, y, 1, - lightning_line_callback_drag); + api->line((void *)api, which, canvas, snapshot, sx, sy, x, y, 1, lightning_line_callback_drag); } void lightning_release(magic_api * api, int which 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) { float a, b, len, angle; int thickness; @@ -194,8 +175,7 @@ lightning_release(magic_api * api, int which ATTRIBUTE_UNUSED, #ifdef DEBUG printf - ("(%d,%d)->(%d,%d) => a = %.2f, b = %.2f, c (len) = %.2f; angle = %.2f degrees\n", - sx, sy, x, y, a, b, len, angle); + ("(%d,%d)->(%d,%d) => a = %.2f, b = %.2f, c (len) = %.2f; angle = %.2f degrees\n", sx, sy, x, y, a, b, len, angle); fflush(stdout); #endif @@ -203,13 +183,11 @@ lightning_release(magic_api * api, int which ATTRIBUTE_UNUSED, if (thickness < 4) thickness = 4; - lightning_draw_bolt((void *) api, canvas, snapshot, (float) sx, (float) sy, - angle, len, thickness); + lightning_draw_bolt((void *)api, canvas, snapshot, (float)sx, (float)sy, angle, len, thickness); } void lightning_draw_bolt(void *ptr, SDL_Surface * canvas, - SDL_Surface * snapshot, float sx, float sy, - float angle, float len, int thickness) + SDL_Surface * snapshot, float sx, float sy, float angle, float len, int thickness) { magic_api *api = (magic_api *) ptr; float i; @@ -232,7 +210,7 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas, x = x + cos(angle * M_PI / 180.0); y = y + sin(angle * M_PI / 180.0); - angle = angle + ((float) (rand() % 15) - 7.5); + angle = angle + ((float)(rand() % 15) - 7.5); if (angle < orig_angle - 10.0) angle = orig_angle - 10.0; else if (angle > orig_angle + 10.0) @@ -249,8 +227,7 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas, light_h = lightning_h; light_s = lightning_s; - SDL_GetRGB(api->getpixel(canvas, x + xx, y + yy), canvas->format, - &r, &g, &b); + SDL_GetRGB(api->getpixel(canvas, x + xx, y + yy), canvas->format, &r, &g, &b); api->rgbtohsv(r, g, b, &h, &s, &v); adj = 1.0 - (sqrt((xx * xx) + (yy * yy)) / t); @@ -275,46 +252,41 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas, api->hsvtorgb(new_h, new_s, new_v, &r, &g, &b); - api->putpixel(canvas, x + xx, y + yy, - SDL_MapRGB(canvas->format, r, g, b)); + api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b)); } } } - if (((rand() % 50) == 0 || (int) i == (int) (len / 2)) && thickness > 1 - && len >= 4) + if (((rand() % 50) == 0 || (int)i == (int)(len / 2)) && thickness > 1 && len >= 4) { float new_angle; if ((rand() % 10) == 0) { - new_angle = angle + ((float) (rand() % 180) - 90.0); + new_angle = angle + ((float)(rand() % 180) - 90.0); } else { - new_angle = angle + ((float) (rand() % 90) - 45.0); + new_angle = angle + ((float)(rand() % 90) - 45.0); } - lightning_draw_bolt((void *) api, canvas, snapshot, x, y, - new_angle, - ((len / 8) + (rand() % (int) (len / 4))), - thickness - 1); + lightning_draw_bolt((void *)api, canvas, snapshot, x, y, + new_angle, ((len / 8) + (rand() % (int)(len / 4))), thickness - 1); } } } void lightning_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { api->rgbtohsv(r, g, b, &lightning_h, &lightning_s, &lightning_v); } void lightning_line_callback_drag(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; @@ -322,15 +294,12 @@ void lightning_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, } void lightning_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 lightning_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) { } @@ -344,6 +313,8 @@ Uint8 lightning_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU return 0; } -void lightning_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 lightning_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) { } diff --git a/magic/src/maze.c b/magic/src/maze.c index 830c57ead..22c4d1739 100644 --- a/magic/src/maze.c +++ b/magic/src/maze.c @@ -28,15 +28,16 @@ int xm[4] = { 0, 0, -1, 1 }; int ym[4] = { -1, 1, 0, 0 }; -typedef struct { +typedef struct +{ int x, y; } maze_start_t; Mix_Chunk *snd_effect = NULL; -Uint8 * maze_mask = NULL, * new_maze_mask = NULL, * maze_array = NULL; -Uint32 * maze_color; -maze_start_t * maze_starts; -SDL_Surface * maze_snapshot = NULL; +Uint8 *maze_mask = NULL, *new_maze_mask = NULL, *maze_array = NULL; +Uint32 *maze_color; +maze_start_t *maze_starts; +SDL_Surface *maze_snapshot = NULL; Uint8 maze_r, maze_g, maze_b; int maze_start_x, maze_start_y; int num_maze_starts = 0, maze_starts_size = 0; @@ -52,23 +53,17 @@ int maze_requires_colors(magic_api * api, int which); int maze_modes(magic_api * api, int which); void maze_shutdown(magic_api * api); void maze_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 maze_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void maze_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 maze_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void maze_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void maze_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); void maze_render(magic_api * api, SDL_Surface * canvas); -void maze_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void maze_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void maze_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void maze_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void zero_maze_arrays(SDL_Surface * canvas); void draw_hall(SDL_Surface * canvas, int x, int y); void maze_add_start(void); @@ -76,7 +71,8 @@ int check_arrays(void); void maze_collapse_contiguous(SDL_Surface * canvas); Uint8 maze_accepted_sizes(magic_api * api, int which, int mode); Uint8 maze_default_size(magic_api * api, int which, int mode); -void maze_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void maze_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 maze_api_version(void) @@ -88,8 +84,7 @@ int maze_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/maze.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/maze.ogg", api->data_directory); snd_effect = Mix_LoadWAV(fname); return (1); @@ -105,42 +100,35 @@ SDL_Surface *maze_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/maze.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/maze.png", api->data_directory); return (IMG_Load(fname)); } -char *maze_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *maze_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext("Maze")); } -int maze_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int maze_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } -char *maze_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode) +char *maze_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return(gettext("Click and drag to paint a maze on your picture.")); + return (gettext("Click and drag to paint a maze on your picture.")); else - return(gettext("Click to turn your entire picture into a maze.")); + return (gettext("Click to turn your entire picture into a maze.")); } -int maze_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int maze_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } -int maze_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int maze_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT | MODE_FULLSCREEN; } @@ -164,18 +152,19 @@ void maze_shutdown(magic_api * api ATTRIBUTE_UNUSED) } /* FIXME */ -int check_arrays(void) { +int check_arrays(void) +{ if (maze_array == NULL || maze_mask == NULL || new_maze_mask == NULL || - maze_color == NULL || maze_snapshot == NULL || maze_starts == NULL) { - return(0); + maze_color == NULL || maze_snapshot == NULL || maze_starts == NULL) + { + return (0); } - return(1); + return (1); } void maze_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) { if (!check_arrays()) return; @@ -186,9 +175,12 @@ maze_click(magic_api * api, int which, int mode, maze_start_x = floor(x / MAZE_BLOCK_SIZE) * MAZE_BLOCK_SIZE + (MAZE_BLOCK_SIZE / 2); maze_start_y = floor(y / MAZE_BLOCK_SIZE) * MAZE_BLOCK_SIZE + (MAZE_BLOCK_SIZE / 2); - if (mode == MODE_PAINT) { + if (mode == MODE_PAINT) + { maze_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); - } else { + } + else + { Uint32 color; maze_add_start(); @@ -216,14 +208,13 @@ maze_click(magic_api * api, int which, int mode, void maze_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) + SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { if (!check_arrays()) return; - api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1, - maze_line_callback_drag); + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, maze_line_callback_drag); update_rect->x = 0; update_rect->y = 0; @@ -234,8 +225,8 @@ maze_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, void maze_release(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect) { + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) +{ if (snd_effect != NULL) api->stopsound(); @@ -266,27 +257,34 @@ void maze_render(magic_api * api, SDL_Surface * canvas) /* Reset everything we've drawn [back to] wall: */ memset(maze_array, MAZE_HALL, (canvas->w * canvas->h)); - for (y = 0; y < canvas->h; y++) { - for (x = 0; x < canvas->w; x++) { - if (maze_mask[y * canvas->w + x]) { + for (y = 0; y < canvas->h; y++) + { + for (x = 0; x < canvas->w; x++) + { + if (maze_mask[y * canvas->w + x]) + { maze_array[y * canvas->w + x] = MAZE_WALL; } } } /* Render a maze! */ - for (s = 0; s < num_maze_starts; s++) { + for (s = 0; s < num_maze_starts; s++) + { x = maze_starts[s].x; y = maze_starts[s].y; /* Render from here, ONLY if it's still non-contiguous to anything: */ - if (maze_mask[y * canvas->w + x] == s + 1) { + if (maze_mask[y * canvas->w + x] == s + 1) + { maze_array[y * canvas->w + x] = MAZE_START; state = STATE_PICKDIR; iter = 0; - do { - if (state == STATE_PICKDIR) { + do + { + if (state == STATE_PICKDIR) + { dir = (rand() % 4); old_dir = dir; } @@ -296,7 +294,8 @@ void maze_render(magic_api * api, SDL_Surface * canvas) nx = x + (xm[dir] * MAZE_BLOCK_SIZE * 2); ny = y + (ym[dir] * MAZE_BLOCK_SIZE * 2); - if (nx >= 0 && nx < canvas->w && ny >= 0 && ny < canvas->h && maze_array[ny * canvas->w + nx] == MAZE_WALL) { + if (nx >= 0 && nx < canvas->w && ny >= 0 && ny < canvas->h && maze_array[ny * canvas->w + nx] == MAZE_WALL) + { draw_hall(canvas, nx, ny); maze_array[ny * canvas->w + nx] = dir + 1; @@ -310,18 +309,21 @@ void maze_render(magic_api * api, SDL_Surface * canvas) state = STATE_PICKDIR; } - if (state == STATE_DONE) { + if (state == STATE_DONE) + { dir = (dir + 1) % 4; if (dir != old_dir) state = STATE_KEEPGOING; } - if (state == STATE_DONE) { + if (state == STATE_DONE) + { dir = maze_array[y * canvas->w + x]; draw_hall(canvas, x, y); - if (dir != MAZE_START) { + if (dir != MAZE_START) + { x = x - (xm[dir - 1] * MAZE_BLOCK_SIZE * 2); y = y - (ym[dir - 1] * MAZE_BLOCK_SIZE * 2); @@ -335,11 +337,16 @@ void maze_render(magic_api * api, SDL_Surface * canvas) } /* Draw the maze onto the canvas */ - for (y = 0; y < canvas->h; y++) { - for (x = 0; x < canvas->w; x++) { - if (maze_array[y * canvas->w + x] == MAZE_WALL) { + for (y = 0; y < canvas->h; y++) + { + for (x = 0; x < canvas->w; x++) + { + if (maze_array[y * canvas->w + x] == MAZE_WALL) + { api->putpixel(canvas, x, y, maze_color[y * canvas->w + x]); - } else { + } + else + { api->putpixel(canvas, x, y, api->getpixel(maze_snapshot, x, y)); } } @@ -348,7 +355,8 @@ void maze_render(magic_api * api, SDL_Surface * canvas) void maze_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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { maze_r = r; maze_g = g; @@ -357,9 +365,7 @@ void maze_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED void maze_line_callback_drag(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; int xx, yy, idx; @@ -373,12 +379,17 @@ void maze_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, x = floor(x / (MAZE_BLOCK_SIZE * 3)) * (MAZE_BLOCK_SIZE * 3); y = floor(y / (MAZE_BLOCK_SIZE * 3)) * (MAZE_BLOCK_SIZE * 3); - for (yy = -MAZE_PAINT_RADIUS; yy < MAZE_PAINT_RADIUS; yy++) { - if (y + yy > 0 && y + yy < canvas->h) { - for (xx = -MAZE_PAINT_RADIUS; xx < MAZE_PAINT_RADIUS; xx++) { - if (x + xx > 0 && x + xx < canvas->w) { + for (yy = -MAZE_PAINT_RADIUS; yy < MAZE_PAINT_RADIUS; yy++) + { + if (y + yy > 0 && y + yy < canvas->h) + { + for (xx = -MAZE_PAINT_RADIUS; xx < MAZE_PAINT_RADIUS; xx++) + { + if (x + xx > 0 && x + xx < canvas->w) + { idx = (y + yy) * canvas->w + (x + xx); - if (maze_mask[idx] == 0) { + if (maze_mask[idx] == 0) + { maze_mask[idx] = num_maze_starts + 1; } maze_color[idx] = color; @@ -390,80 +401,77 @@ void maze_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED, } void maze_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { if (maze_array == NULL) + { + maze_array = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (maze_array == NULL) { - maze_array = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (maze_array == NULL) - { - fprintf(stderr, "maze: Cannot malloc() maze_array!\n"); - return; - } + fprintf(stderr, "maze: Cannot malloc() maze_array!\n"); + return; } + } if (maze_mask == NULL) + { + maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (maze_mask == NULL) { - maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (maze_mask == NULL) - { - fprintf(stderr, "maze: Cannot malloc() maze_mask!\n"); - return; - } + fprintf(stderr, "maze: Cannot malloc() maze_mask!\n"); + return; } + } if (new_maze_mask == NULL) + { + new_maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); + if (new_maze_mask == NULL) { - new_maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (new_maze_mask == NULL) - { - fprintf(stderr, "new_maze: Cannot malloc() maze_mask!\n"); - return; - } + fprintf(stderr, "new_maze: Cannot malloc() maze_mask!\n"); + return; } + } if (maze_color == NULL) + { + maze_color = (Uint32 *) malloc(sizeof(Uint32) * canvas->w * canvas->h); + if (maze_color == NULL) { - maze_color = (Uint32 *) malloc(sizeof(Uint32) * canvas->w * canvas->h); - if (maze_color == NULL) - { - fprintf(stderr, "maze: Cannot malloc() maze_color!\n"); - return; - } + fprintf(stderr, "maze: Cannot malloc() maze_color!\n"); + return; } + } if (maze_starts == NULL) - { - int w, h; - w = ceil(canvas->w / MAZE_BLOCK_SIZE); - h = ceil(canvas->h / MAZE_BLOCK_SIZE); - maze_starts_size = (w * h); + { + int w, h; - maze_starts = (maze_start_t *) malloc(sizeof(maze_start_t) * maze_starts_size); - if (maze_starts == NULL) - { - fprintf(stderr, "maze: Cannot malloc() maze_starts!\n"); - return; - } + w = ceil(canvas->w / MAZE_BLOCK_SIZE); + h = ceil(canvas->h / MAZE_BLOCK_SIZE); + maze_starts_size = (w * h); + + maze_starts = (maze_start_t *) malloc(sizeof(maze_start_t) * maze_starts_size); + if (maze_starts == NULL) + { + fprintf(stderr, "maze: Cannot malloc() maze_starts!\n"); + return; } + } zero_maze_arrays(canvas); if (maze_snapshot == NULL) maze_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, - canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->BitsPerPixel, canvas->format->Rmask, + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); if (maze_snapshot != NULL) SDL_BlitSurface(canvas, NULL, maze_snapshot, NULL); } void maze_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) { zero_maze_arrays(canvas); } @@ -485,13 +493,18 @@ void zero_maze_arrays(SDL_Surface * canvas) memset(maze_color, 0, (sizeof(Uint32) * (canvas->w * canvas->h))); } -void draw_hall(SDL_Surface * canvas, int x, int y) { +void draw_hall(SDL_Surface * canvas, int x, int y) +{ int xx, yy; - for (yy = -MAZE_BLOCK_SIZE / 2; yy < MAZE_BLOCK_SIZE / 2; yy++) { - if (y + yy >= 0 && y + yy < canvas->h) { - for (xx = -MAZE_BLOCK_SIZE / 2; xx < MAZE_BLOCK_SIZE / 2; xx++) { - if (x + xx >= 0 && x + xx < canvas->w) { + for (yy = -MAZE_BLOCK_SIZE / 2; yy < MAZE_BLOCK_SIZE / 2; yy++) + { + if (y + yy >= 0 && y + yy < canvas->h) + { + for (xx = -MAZE_BLOCK_SIZE / 2; xx < MAZE_BLOCK_SIZE / 2; xx++) + { + if (x + xx >= 0 && x + xx < canvas->w) + { maze_array[(y + yy) * canvas->w + (x + xx)] = MAZE_HALL; } } @@ -499,42 +512,59 @@ void draw_hall(SDL_Surface * canvas, int x, int y) { } } -void maze_add_start(void) { +void maze_add_start(void) +{ maze_starts[num_maze_starts].x = maze_start_x; maze_starts[num_maze_starts].y = maze_start_y; num_maze_starts++; } -void maze_collapse_contiguous(SDL_Surface * canvas) { +void maze_collapse_contiguous(SDL_Surface * canvas) +{ int i, x, y, touching, idx; - for (i = num_maze_starts; i > 0; i--) { + for (i = num_maze_starts; i > 0; i--) + { touching = -1; - for (y = 1; y < canvas->h - 1 && touching == -1; y++) { - for (x = 1; x < canvas->w - 1 && touching == -1; x++) { + for (y = 1; y < canvas->h - 1 && touching == -1; y++) + { + for (x = 1; x < canvas->w - 1 && touching == -1; x++) + { idx = (y * canvas->w + x); - if (maze_mask[idx] == i + 1) { - if (maze_mask[idx - 1] != 0 && maze_mask[idx - 1] != i + 1) { + if (maze_mask[idx] == i + 1) + { + if (maze_mask[idx - 1] != 0 && maze_mask[idx - 1] != i + 1) + { touching = maze_mask[idx - 1]; - } else if (maze_mask[idx + 1] != 0 && maze_mask[idx + 1] != i + 1) { + } + else if (maze_mask[idx + 1] != 0 && maze_mask[idx + 1] != i + 1) + { touching = maze_mask[idx + 1]; - } else if (maze_mask[idx - canvas->w] != 0 && maze_mask[idx - canvas->w] != i + 1) { + } + else if (maze_mask[idx - canvas->w] != 0 && maze_mask[idx - canvas->w] != i + 1) + { touching = maze_mask[idx - canvas->w]; - } else if (maze_mask[idx + canvas->w] != 0 && maze_mask[idx + canvas->w] != i + 1) { + } + else if (maze_mask[idx + canvas->w] != 0 && maze_mask[idx + canvas->w] != i + 1) + { touching = maze_mask[idx + canvas->w]; } } } } - if (touching != -1) { + if (touching != -1) + { /* Touching someone else; turn all of our area into that area */ - for (y = 1; y < canvas->h; y++) { - for (x = 1; x < canvas->w; x++) { + for (y = 1; y < canvas->h; y++) + { + for (x = 1; x < canvas->w; x++) + { idx = (y * canvas->w + x); - if (maze_mask[idx] == i + 1) { + if (maze_mask[idx] == i + 1) + { maze_mask[idx] = touching; } } @@ -553,6 +583,8 @@ Uint8 maze_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 0; } -void maze_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 maze_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) { } diff --git a/magic/src/metalpaint.c b/magic/src/metalpaint.c index 6b2510ffa..47edb5274 100644 --- a/magic/src/metalpaint.c +++ b/magic/src/metalpaint.c @@ -45,29 +45,24 @@ SDL_Surface *metalpaint_get_icon(magic_api * api, int which); char *metalpaint_get_name(magic_api * api, int which); int metalpaint_get_group(magic_api * api, int which); char *metalpaint_get_description(magic_api * api, int which, int mode); -static void do_metalpaint(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_metalpaint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void metalpaint_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); void metalpaint_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 metalpaint_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void metalpaint_shutdown(magic_api * api); void metalpaint_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int metalpaint_requires_colors(magic_api * api, int which); -void metalpaint_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void metalpaint_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void metalpaint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void metalpaint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int metalpaint_modes(magic_api * api, int which); Uint8 metalpaint_accepted_sizes(magic_api * api, int which, int mode); Uint8 metalpaint_default_size(magic_api * api, int which, int mode); -void metalpaint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void metalpaint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 metalpaint_api_version(void) @@ -81,8 +76,7 @@ int metalpaint_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/metalpaint.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/metalpaint.wav", api->data_directory); metalpaint_snd = Mix_LoadWAV(fname); return (1); @@ -99,34 +93,28 @@ SDL_Surface *metalpaint_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/metalpaint.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/metalpaint.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *metalpaint_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *metalpaint_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Metal Paint"))); } // Return our groups: -int metalpaint_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int metalpaint_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: char *metalpaint_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag the mouse to paint with a metallic color."))); + return (strdup(gettext_noop("Click and drag the mouse to paint with a metallic color."))); } #define METALPAINT_CYCLE 32 @@ -143,8 +131,7 @@ static int metalpaint_gradient[METALPAINT_CYCLE] = { // Do the effect: static void do_metalpaint(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -161,19 +148,16 @@ static void do_metalpaint(void *ptr, int which ATTRIBUTE_UNUSED, g = (metalpaint_g * n) / 255; b = (metalpaint_b * n) / 255; - api->putpixel(canvas, x + xx, y + yy, - SDL_MapRGB(canvas->format, r, g, b)); + api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b)); } } } // Affect the canvas on drag: void metalpaint_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_metalpaint); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_metalpaint); if (ox > x) { @@ -200,8 +184,7 @@ void metalpaint_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void metalpaint_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) { metalpaint_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -211,8 +194,7 @@ void metalpaint_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -224,8 +206,9 @@ void metalpaint_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void metalpaint_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 metalpaint_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) { metalpaint_r = min(255, r + 64); metalpaint_g = min(255, g + 64); @@ -233,28 +216,22 @@ void metalpaint_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ } // Use colors: -int metalpaint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int metalpaint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } void metalpaint_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 metalpaint_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 metalpaint_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int metalpaint_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -270,7 +247,9 @@ Uint8 metalpaint_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB return 2; } -void metalpaint_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 metalpaint_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) { metalpaint_size = size * 4; } diff --git a/magic/src/mirror_flip.c b/magic/src/mirror_flip.c index 016c39e01..525a87f7d 100644 --- a/magic/src/mirror_flip.c +++ b/magic/src/mirror_flip.c @@ -51,12 +51,9 @@ SDL_Surface *mirror_flip_get_icon(magic_api *, int); char *mirror_flip_get_name(magic_api *, int); int mirror_flip_get_group(magic_api *, int); char *mirror_flip_get_description(magic_api *, int, int); -void mirror_flip_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, - int, int, int, SDL_Rect *); -void mirror_flip_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, - int, int, int, SDL_Rect *); -void mirror_flip_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, - int, int, SDL_Rect *); +void mirror_flip_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *); +void mirror_flip_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *); +void mirror_flip_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); void mirror_flip_shutdown(magic_api *); void mirror_flip_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); @@ -66,19 +63,18 @@ void mirror_flip_switchout(magic_api *, int, int, SDL_Surface *); int mirror_flip_modes(magic_api *, int); Uint8 mirror_flip_accepted_sizes(magic_api * api, int which, int mode); Uint8 mirror_flip_default_size(magic_api * api, int which, int mode); -void mirror_flip_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void mirror_flip_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: int mirror_flip_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/mirror.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/mirror.wav", api->data_directory); snd_effects[TOOL_MIRROR] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/flip.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/flip.wav", api->data_directory); snd_effects[TOOL_FLIP] = Mix_LoadWAV(fname); return (1); @@ -102,13 +98,11 @@ SDL_Surface *mirror_flip_get_icon(magic_api * api, int which) if (which == TOOL_MIRROR) { - snprintf(fname, sizeof(fname), "%simages/magic/mirror.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/mirror.png", api->data_directory); } else if (which == TOOL_FLIP) { - snprintf(fname, sizeof(fname), "%simages/magic/flip.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/flip.png", api->data_directory); } return (IMG_Load(fname)); @@ -126,15 +120,13 @@ char *mirror_flip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (the same): -int mirror_flip_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mirror_flip_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } // Return our descriptions, localized: -char *mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { if (which == TOOL_MIRROR) return (strdup(gettext_noop("Click to make a mirror image."))); @@ -150,8 +142,7 @@ void mirror_flip_drag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy 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) { // No-op } @@ -161,8 +152,7 @@ void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy 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) { // No-op } @@ -170,8 +160,7 @@ void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED, // Affect the canvas on click: void mirror_flip_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) { int xx, yy; SDL_Rect src, dest; @@ -229,40 +218,37 @@ void mirror_flip_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // We don't use colors: -void mirror_flip_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) +void mirror_flip_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) { } // We don't use colors: -int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void mirror_flip_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 mirror_flip_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 mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_FULLSCREEN); } -Uint8 mirror_flip_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 mirror_flip_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } @@ -272,6 +258,8 @@ Uint8 mirror_flip_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI return 0; } -void mirror_flip_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 mirror_flip_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) { } diff --git a/magic/src/mosaic.c b/magic/src/mosaic.c index ba448e078..bcf07d0b4 100644 --- a/magic/src/mosaic.c +++ b/magic/src/mosaic.c @@ -44,12 +44,9 @@ #define gettext_noop(String) String #endif -static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, - int noise_AMOUNT, int x, int y); -static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, int noise_AMOUNT, int x, int y); +static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y); static void reset_mosaic_blured(SDL_Surface * canvas); /* Prototypes */ @@ -61,12 +58,9 @@ char *mosaic_get_name(magic_api *, int); int mosaic_get_group(magic_api *, int); char *mosaic_get_description(magic_api *, int, int); void mosaic_paint(void *, int, SDL_Surface *, SDL_Surface *, int, int); -void mosaic_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, - int, int, SDL_Rect *); -void mosaic_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, - int, SDL_Rect *); -void mosaic_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, - SDL_Rect *); +void mosaic_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *); +void mosaic_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); +void mosaic_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); void mosaic_shutdown(magic_api *); void mosaic_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); @@ -76,7 +70,8 @@ void mosaic_switchout(magic_api *, int, int, SDL_Surface *); int mosaic_modes(magic_api *, int); Uint8 mosaic_accepted_sizes(magic_api * api, int which, int mode); Uint8 mosaic_default_size(magic_api * api, int which, int mode); -void mosaic_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void mosaic_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); static const int mosaic_AMOUNT = 300; @@ -112,8 +107,7 @@ const int mosaic_groups[mosaic_NUM_TOOLS] = { }; const char *mosaic_descs[mosaic_NUM_TOOLS][2] = { - {gettext_noop - ("Click and drag the mouse to add a mosaic effect to parts of your picture."), + {gettext_noop("Click and drag the mouse to add a mosaic effect to parts of your picture."), gettext_noop("Click to add a mosaic effect to your entire picture."),}, }; @@ -131,8 +125,7 @@ int mosaic_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < mosaic_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - mosaic_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, mosaic_snd_filenames[i]); mosaic_snd_effect[i] = Mix_LoadWAV(fname); } @@ -149,8 +142,7 @@ SDL_Surface *mosaic_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - mosaic_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, mosaic_icon_filenames[which]); return (IMG_Load(fname)); } @@ -167,8 +159,7 @@ int mosaic_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *mosaic_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *mosaic_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(mosaic_descs[which][mode - 1]))); } @@ -181,21 +172,18 @@ static int mosaic_grey(Uint8 r1, Uint8 g1, Uint8 b1) // Do the effect for the full image static void do_mosaic_full(void *ptr, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) + SDL_Surface * last ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { magic_api *api = (magic_api *) ptr; int x, y; - Uint32 amask = - ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); + Uint32 amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); SDL_Surface *mosaic_temp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, - canvas->format-> - BitsPerPixel, + canvas->format->BitsPerPixel, canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, @@ -229,21 +217,17 @@ static void do_mosaic_full(void *ptr, SDL_Surface * canvas, /* Paint the brush, noise is yet done at switchin, blurs 2 pixels around the brush in order to get sharpen well done.*/ void mosaic_paint(void *ptr_to_api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { int i, j, pix_row_pos; magic_api *api = (magic_api *) ptr_to_api; - for (j = max(0, y - mosaic_RADIUS - 2); - j < min(canvas->h, y + mosaic_RADIUS + 2); j++) + for (j = max(0, y - mosaic_RADIUS - 2); j < min(canvas->h, y + mosaic_RADIUS + 2); j++) { pix_row_pos = j * canvas->w; - for (i = max(0, x - mosaic_RADIUS - 2); - i < min(canvas->w, x + mosaic_RADIUS + 2); i++) - if (!mosaic_blured[pix_row_pos + i] - && api->in_circle(i - x, j - y, mosaic_RADIUS + 2)) + for (i = max(0, x - mosaic_RADIUS - 2); i < min(canvas->w, x + mosaic_RADIUS + 2); i++) + if (!mosaic_blured[pix_row_pos + i] && api->in_circle(i - x, j - y, mosaic_RADIUS + 2)) { mosaic_blur_pixel(api, canvas_blur, canvas_noise, i, j); mosaic_blured[pix_row_pos + i] = 1; /* Track what are yet blured */ @@ -262,8 +246,7 @@ void mosaic_paint(void *ptr_to_api, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void mosaic_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(api, which, canvas, last, ox, oy, x, y, 1, mosaic_paint); @@ -277,8 +260,7 @@ void mosaic_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void mosaic_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_FULLSCREEN) @@ -302,8 +284,7 @@ void mosaic_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -323,21 +304,21 @@ void mosaic_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void mosaic_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) +void mosaic_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) { } // Use colors: -int mosaic_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mosaic_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } //Add noise to a pixel -static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, - int noise_AMOUNT, int x, int y) +static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, int noise_AMOUNT, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -345,21 +326,16 @@ static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, double temp2[3]; int k; - SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], - &temp[2]); + SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]); for (k = 0; k < 3; k++) { - temp2[k] = - clamp(0.0, (int) temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, - 255.0); + temp2[k] = clamp(0.0, (int)temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, 255.0); } - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); } //Blur a pixel -static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; int i, j, k; @@ -384,8 +360,7 @@ static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, for (j = -2; j < 3; j++) { //Add the pixels around the current one wieghted - SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], - &temp[1], &temp[2]); + SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], &temp[1], &temp[2]); for (k = 0; k < 3; k++) { blurValue[k] += temp[k] * weight[i + 2][j + 2]; @@ -396,14 +371,11 @@ static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, { blurValue[k] /= 273; } - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], - blurValue[2])); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], blurValue[2])); } //Sharpen a pixel -static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -431,8 +403,7 @@ static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, for (j = -1; j < 2; j++) { //No need to check if inside canvas, getpixel does it for us. - SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, - &b1); + SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, &b1); grey = mosaic_grey(r1, g1, b1); sobel_1 += grey * sobel_weights_1[i + 1][j + 1]; sobel_2 += grey * sobel_weights_2[i + 1][j + 1]; @@ -451,8 +422,7 @@ static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, } -void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) +void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { int y, x; Uint32 amask; @@ -464,16 +434,13 @@ void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, exit(1); } - amask = - ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); + amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); canvas_noise = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); SDL_BlitSurface(canvas, NULL, canvas_noise, NULL); @@ -489,23 +456,18 @@ void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); canvas_sharp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); reset_mosaic_blured(canvas); } void mosaic_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) { SDL_FreeSurface(canvas_noise); SDL_FreeSurface(canvas_blur); @@ -542,8 +504,9 @@ Uint8 mosaic_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 4; } -void mosaic_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 mosaic_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) { mosaic_RADIUS = size * 4; } - diff --git a/magic/src/mosaic_shaped.c b/magic/src/mosaic_shaped.c index 8b791ecec..63b9f03d0 100644 --- a/magic/src/mosaic_shaped.c +++ b/magic/src/mosaic_shaped.c @@ -48,20 +48,14 @@ #define gettext_noop(String) String #endif -static void mosaic_shaped_sharpen_pixel(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void mosaic_shaped_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y); static void reset_counter(SDL_Surface * canvas, Uint8 * counter); -static void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, - int size, Uint32 color); +static void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, int size, Uint32 color); static void deform(magic_api * api, SDL_Surface * srfc); static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int which, - SDL_Rect * update_rect); -static void mosaic_shaped_fill(void *ptr_to_api, int which, - SDL_Surface * canvas, SDL_Surface * last, - int x, int y); -static void mosaic_shaped_paint(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); + SDL_Surface * last, int which, SDL_Rect * update_rect); +static void mosaic_shaped_fill(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void mosaic_shaped_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); Uint32 mosaic_shaped_api_version(void); int mosaic_shaped_init(magic_api * api, Uint32 disabled_features); @@ -73,16 +67,13 @@ int mosaic_shaped_get_group(magic_api * api, int which); char *mosaic_shaped_get_description(magic_api * api, int which, int mode); void mosaic_shaped_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); void mosaic_shaped_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 mosaic_shaped_release(magic_api * api, int which, - 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 mosaic_shaped_shutdown(magic_api * api); @@ -91,28 +82,25 @@ void mosaic_shaped_set_color(magic_api * api, int which, SDL_Surface * canvas, int mosaic_shaped_requires_colors(magic_api * api, int which); -void mosaic_shaped_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void mosaic_shaped_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); -void mosaic_shaped_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void mosaic_shaped_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int mosaic_shaped_modes(magic_api * api, int which); int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, - int x, int y, int fill_edge, int fill_tile, int size, - Uint32 color); + int x, int y, int fill_edge, int fill_tile, int size, Uint32 color); Uint8 mosaic_shaped_accepted_sizes(magic_api * api, int which, int mode); Uint8 mosaic_shaped_default_size(magic_api * api, int which, int mode); -void mosaic_shaped_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void mosaic_shaped_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint8 *mosaic_shaped_counted; Uint8 *mosaic_shaped_done; Uint8 mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b; -int mosaic_shaped_average_r, mosaic_shaped_average_g, mosaic_shaped_average_b, - mosaic_shaped_average_count; +int mosaic_shaped_average_r, mosaic_shaped_average_g, mosaic_shaped_average_b, mosaic_shaped_average_count; Uint32 pixel_average, black, white; enum @@ -155,20 +143,17 @@ const char *mosaic_shaped_names[mosaic_shaped_NUM_TOOLS] = { const char *mosaic_shaped_descs[mosaic_shaped_NUM_TOOLS][2] = { { - gettext_noop - ("Click and drag the mouse to add a square mosaic to parts of your picture."), + gettext_noop("Click and drag the mouse to add a square mosaic to parts of your picture."), gettext_noop("Click to add a square mosaic to your entire picture."), }, { - gettext_noop - ("Click and drag the mouse to add a hexagonal mosaic to parts of your picture."), + gettext_noop("Click and drag the mouse to add a hexagonal mosaic to parts of your picture."), gettext_noop("Click to add a hexagonal mosaic to your entire picture."), }, { - gettext_noop - ("Click and drag the mouse to add an irregular mosaic to parts of your picture."), + gettext_noop("Click and drag the mouse to add an irregular mosaic to parts of your picture."), gettext_noop("Click to add an irregular mosaic to your entire picture."), }, }; @@ -188,8 +173,7 @@ int mosaic_shaped_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSE for (i = 0; i < mosaic_shaped_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - mosaic_shaped_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, mosaic_shaped_snd_filenames[i]); mosaic_shaped_snd_effect[i] = Mix_LoadWAV(fname); } @@ -206,8 +190,7 @@ SDL_Surface *mosaic_shaped_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - mosaic_shaped_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, mosaic_shaped_icon_filenames[which]); return (IMG_Load(fname)); } @@ -218,15 +201,13 @@ char *mosaic_shaped_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our groups (all the same!) -int mosaic_shaped_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mosaic_shaped_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *mosaic_shaped_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which, int mode) +char *mosaic_shaped_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(mosaic_shaped_descs[which][mode - 1]))); } @@ -240,16 +221,13 @@ static int mosaic_shaped_grey(Uint8 r1, Uint8 g1, Uint8 b1) // Do the effect for the full image static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { int i, j, size; Uint32 mosaic_shaped_color; magic_api *api = (magic_api *) ptr; - mosaic_shaped_color = - SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, - mosaic_shaped_b, 0); + mosaic_shaped_color = SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b, 0); for (i = 3; i < canvas->w - 3; i += 2) { @@ -266,8 +244,7 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, mosaic_shaped_average_g = 0; mosaic_shaped_average_b = 0; mosaic_shaped_average_count = 0; - scan_fill(api, canvas, canvas_shaped, i, j, 1, 0, 1, - mosaic_shaped_color); + scan_fill(api, canvas, canvas_shaped, i, j, 1, 0, 1, mosaic_shaped_color); if (mosaic_shaped_average_count > 0) { @@ -278,11 +255,8 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, mosaic_shaped_average_r / mosaic_shaped_average_count, mosaic_shaped_average_g / - mosaic_shaped_average_count, - mosaic_shaped_average_b / - mosaic_shaped_average_count); - scan_fill(api, canvas, canvas_shaped, i, j, 0, 1, size, - pixel_average); + mosaic_shaped_average_count, mosaic_shaped_average_b / mosaic_shaped_average_count); + scan_fill(api, canvas, canvas_shaped, i, j, 0, 1, size, pixel_average); } } } @@ -291,9 +265,7 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, /* Fills a tesera */ static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, - int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { Uint32 mosaic_shaped_color; int size; @@ -301,9 +273,7 @@ static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED, x = clamp(0, x, canvas->w - 1); y = clamp(0, y, canvas->h - 1); - mosaic_shaped_color = - SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, - mosaic_shaped_b, 0); + mosaic_shaped_color = SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b, 0); mosaic_shaped_average_r = 0; mosaic_shaped_average_g = 0; mosaic_shaped_average_b = 0; @@ -331,8 +301,7 @@ static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void mosaic_shaped_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(api, which, canvas, last, ox, oy, x, y, 1, mosaic_shaped_fill); update_rect->x = min(ox, x) - mosaic_shaped_pattern->w; @@ -344,8 +313,7 @@ void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void mosaic_shaped_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_FULLSCREEN) { @@ -367,8 +335,7 @@ void mosaic_shaped_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -388,8 +355,9 @@ void mosaic_shaped_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void mosaic_shaped_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 mosaic_shaped_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) { mosaic_shaped_r = r; mosaic_shaped_g = g; @@ -397,16 +365,14 @@ void mosaic_shaped_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU } // Use colors: -int mosaic_shaped_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mosaic_shaped_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } //Sharpen a pixel static void mosaic_shaped_sharpen_pixel(void *ptr, - SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last, int x, int y) + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; Uint8 r1, g1, b1; @@ -432,8 +398,7 @@ static void mosaic_shaped_sharpen_pixel(void *ptr, for (j = -1; j < 2; j++) { //No need to check if inside canvas, getpixel does it for us. - SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, - &b1); + SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, &b1); grey = mosaic_shaped_grey(r1, g1, b1); sobel_1 += grey * sobel_weights_1[i + 1][j + 1]; sobel_2 += grey * sobel_weights_2[i + 1][j + 1]; @@ -445,15 +410,13 @@ static void mosaic_shaped_sharpen_pixel(void *ptr, if (temp > 25) { - api->putpixel(canvas_shaped, x, y, - SDL_MapRGBA(canvas_shaped->format, 0, 0, 0, 0)); + api->putpixel(canvas_shaped, x, y, SDL_MapRGBA(canvas_shaped->format, 0, 0, 0, 0)); } } -void mosaic_shaped_switchin(magic_api * api, int which, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) +void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { int y, x; int i, j; @@ -461,8 +424,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, SDL_Surface *surf_aux, *tmp, *tmp2; Uint32 amask; - mosaic_shaped_counted = - (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); + mosaic_shaped_counted = (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); if (mosaic_shaped_counted == NULL) { @@ -470,8 +432,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, exit(1); } - mosaic_shaped_done = - (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); + mosaic_shaped_done = (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); if (mosaic_shaped_done == NULL) { @@ -479,15 +440,13 @@ void mosaic_shaped_switchin(magic_api * api, int which, exit(1); } - amask = - ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); + amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); canvas_shaped = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_RGB888, 0); SDL_FreeSurface(tmp); @@ -495,8 +454,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, canvas->w + 10, canvas->h + 10, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); surf_aux = SDL_ConvertSurfaceFormat(tmp2, SDL_PIXELFORMAT_RGB888, 0); SDL_FreeSurface(tmp2); @@ -509,58 +467,41 @@ void mosaic_shaped_switchin(magic_api * api, int which, 16, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, - amask); + canvas->format->Gmask, canvas->format->Bmask, amask); SDL_FillRect(mosaic_shaped_pattern, NULL, - SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE)); /* Shape */ for (i = 0; i < mosaic_shaped_pattern->w; i++) { - api->putpixel(mosaic_shaped_pattern, 0, i, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 0, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 1, i, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, i, 0, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, i, 0, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 1, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); } /* Shadow */ for (i = 1; i < mosaic_shaped_pattern->w - 1; i++) { api->putpixel(mosaic_shaped_pattern, 1, i, - SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 2, i, - SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, i, 1, - SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 2, - SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE)); } api->putpixel(mosaic_shaped_pattern, 2, 2, - SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, 2, mosaic_shaped_pattern->h - 3, - SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 3, 2, - SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE)); api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 3, mosaic_shaped_pattern->h - 3, - SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE)); } else if (which == TOOL_IRREGULAR) { @@ -569,68 +510,38 @@ void mosaic_shaped_switchin(magic_api * api, int which, 64, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, - amask); + canvas->format->Gmask, canvas->format->Bmask, amask); SDL_FillRect(mosaic_shaped_pattern, NULL, - SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE)); /* Start/end of lines taken from the original mosaic_shaped_irregular_pattern.png */ - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 8, 36, 23, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 43, 36, 23, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 26, 28, 53, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 54, 10, 63, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 55, 0, 36, 23, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 63, 43, 28, 53, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 24, 63, 28, 53, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 63, 8, 50, 6, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 4, 10, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 25, 7, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 41, 0, 26, 12, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 28, 53, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 56, 58, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 63, 53, 55, 45, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 55, 63, 59, 49, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 10, 63, 20, 45, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 63, 26, 40, 18, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 4, 30, 14, 14, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 18, 33, 21, 17, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 23, 48, 29, 27, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 37, 50, 36, 23, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 44, 13, 37, 3, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 59, 24, 55, 7, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 49, 47, 54, 23, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 36, 35, 51, 37, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 1, - mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 8, 36, 23, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 43, 36, 23, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 26, 28, 53, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 54, 10, 63, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 55, 0, 36, 23, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 63, 43, 28, 53, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 24, 63, 28, 53, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 63, 8, 50, 6, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 4, 10, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 25, 7, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 41, 0, 26, 12, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 28, 53, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 56, 58, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 63, 53, 55, 45, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 55, 63, 59, 49, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 10, 63, 20, 45, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 63, 26, 40, 18, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 4, 30, 14, 14, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 18, 33, 21, 17, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 23, 48, 29, 27, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 37, 50, 36, 23, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 44, 13, 37, 3, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 59, 24, 55, 7, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 49, 47, 54, 23, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 36, 35, 51, 37, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 1, mosaic_shaped_paint); } else if (which == TOOL_HEX) @@ -640,45 +551,24 @@ void mosaic_shaped_switchin(magic_api * api, int which, 28, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, - amask); + canvas->format->Gmask, canvas->format->Bmask, amask); SDL_FillRect(mosaic_shaped_pattern, NULL, - SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, - SDL_ALPHA_OPAQUE)); + SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE)); - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 16, 8, 0, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 8, 0, 26, 0, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 26, 0, 32, 14, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 26, 27, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 47, 14, 1, - mosaic_shaped_paint); - api->line(api, which, mosaic_shaped_pattern, NULL, 0, 13, 8, 27, 1, - mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 16, 8, 0, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 8, 0, 26, 0, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 26, 0, 32, 14, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 26, 27, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 47, 14, 1, mosaic_shaped_paint); + api->line(api, which, mosaic_shaped_pattern, NULL, 0, 13, 8, 27, 1, mosaic_shaped_paint); //make pattern more accurate - api->putpixel(mosaic_shaped_pattern, 9, 27, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, 9, 26, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, 26, 27, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, 26, 26, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, 26, 25, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); - api->putpixel(mosaic_shaped_pattern, 25, 27, - SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, - SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 9, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 9, 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 26, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 26, 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 26, 25, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); + api->putpixel(mosaic_shaped_pattern, 25, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE)); } @@ -728,9 +618,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); SDL_BlitSurface(canvas, NULL, canvas_back, NULL); if (which != TOOL_SQUARE) /* The pattern for square is small enouth to not need an additional shape */ @@ -748,8 +636,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { SDL_FreeSurface(canvas_shaped); SDL_FreeSurface(canvas_back); @@ -757,8 +644,7 @@ void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED, free(mosaic_shaped_counted); } -int mosaic_shaped_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int mosaic_shaped_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } @@ -778,8 +664,7 @@ void reset_counter(SDL_Surface * canvas, Uint8 * counter) int scan_fill_count; int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, - int x, int y, int fill_edge, int fill_tile, int size, - Uint32 color) + int x, int y, int fill_edge, int fill_tile, int size, Uint32 color) { int leftx, rightx; Uint8 r, g, b, a; @@ -829,8 +714,7 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, } else { - SDL_GetRGBA(api->getpixel(canvas_back, x, y), canvas_back->format, &r, &g, - &b, &a); + SDL_GetRGBA(api->getpixel(canvas_back, x, y), canvas_back->format, &r, &g, &b, &a); mosaic_shaped_average_r += r; mosaic_shaped_average_g += g; mosaic_shaped_average_b += b; @@ -839,17 +723,13 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, } /* Search right */ - while (scan_fill - (api, canvas, srfc, rightx, y, fill_edge, fill_tile, size, color) - && (rightx < canvas->w)) + while (scan_fill(api, canvas, srfc, rightx, y, fill_edge, fill_tile, size, color) && (rightx < canvas->w)) { rightx++; } /* Search left */ - while (scan_fill - (api, canvas, srfc, leftx, y, fill_edge, fill_tile, size, color) - && (leftx >= 0)) + while (scan_fill(api, canvas, srfc, leftx, y, fill_edge, fill_tile, size, color) && (leftx >= 0)) { leftx--; } @@ -859,14 +739,12 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, { if (y > 0) { - scan_fill(api, canvas, srfc, i, y - 1, fill_edge, fill_tile, size, - color); + scan_fill(api, canvas, srfc, i, y - 1, fill_edge, fill_tile, size, color); } if (y + 1 < canvas->w) { - scan_fill(api, canvas, srfc, i, y + 1, fill_edge, fill_tile, size, - color); + scan_fill(api, canvas, srfc, i, y + 1, fill_edge, fill_tile, size, color); } } @@ -875,8 +753,7 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, } -void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, - int size, Uint32 color) +void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, int size, Uint32 color) { int i, j; @@ -894,23 +771,19 @@ void deform(magic_api * api, SDL_Surface * srfc) for (j = 0; j < srfc->h; j++) for (i = 0; i < srfc->w; i++) { - api->putpixel(srfc, i, j, - api->getpixel(srfc, i + sin(j * M_PI / 90) * 10 + 10, j)); + api->putpixel(srfc, i, j, api->getpixel(srfc, i + sin(j * M_PI / 90) * 10 + 10, j)); } for (i = 0; i < srfc->w; i++) for (j = 0; j < srfc->h; j++) { - api->putpixel(srfc, i, j, - api->getpixel(srfc, i, j + sin(i * M_PI / 90) * 10 + 10)); + api->putpixel(srfc, i, j, api->getpixel(srfc, i, j + sin(i * M_PI / 90) * 10 + 10)); } } /* Paints a 2 pixel square with black and shadows around 3 more pixels */ static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, - int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int radius, shadow; @@ -957,8 +830,7 @@ static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED, if (b > 10) b -= 9; - api->putpixel(canvas, ii, jj, - SDL_MapRGBA(canvas->format, r, g, b, SDL_ALPHA_OPAQUE)); + api->putpixel(canvas, ii, jj, SDL_MapRGBA(canvas->format, r, g, b, SDL_ALPHA_OPAQUE)); } @@ -966,16 +838,20 @@ static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED, } -Uint8 mosaic_shaped_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 mosaic_shaped_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } -Uint8 mosaic_shaped_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 mosaic_shaped_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } -void mosaic_shaped_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 mosaic_shaped_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) { } diff --git a/magic/src/negative.c b/magic/src/negative.c index 04e0f2592..6ead7c503 100644 --- a/magic/src/negative.c +++ b/magic/src/negative.c @@ -42,30 +42,25 @@ SDL_Surface *negative_get_icon(magic_api * api, int which); char *negative_get_name(magic_api * api, int which); int negative_get_group(magic_api * api, int which); char *negative_get_description(magic_api * api, int which, int mode); -static void do_negative(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_negative(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void negative_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); void negative_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 negative_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void negative_shutdown(magic_api * api); void negative_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int negative_requires_colors(magic_api * api, int which); -void negative_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void negative_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void negative_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void negative_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int negative_modes(magic_api * api, int which); Uint8 negative_accepted_sizes(magic_api * api, int which, int mode); Uint8 negative_default_size(magic_api * api, int which, int mode); -void negative_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void negative_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); enum { @@ -86,14 +81,11 @@ const char *negative_names[negative_NUM_TOOLS] = { const char *negative_descs[negative_NUM_TOOLS][2] = { { - gettext_noop - ("Click and drag the mouse around to make your painting negative."), + gettext_noop("Click and drag the mouse around to make your painting negative."), gettext_noop("Click to turn your painting into its negative.")}, { - gettext_noop - ("Click and drag the mouse around to change colors to their opposites -- their complementary colors."), - gettext_noop - ("Click to turn all colors in your painting into their opposites -- their complementary colors.")}, + gettext_noop("Click and drag the mouse around to change colors to their opposites -- their complementary colors."), + gettext_noop("Click to turn all colors in your painting into their opposites -- their complementary colors.")}, }; @@ -101,8 +93,7 @@ int negative_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/negative.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/negative.wav", api->data_directory); negative_snd = Mix_LoadWAV(fname); @@ -124,8 +115,7 @@ SDL_Surface *negative_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - negative_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, negative_icon_filenames[which]); return (IMG_Load(fname)); } @@ -136,15 +126,13 @@ char *negative_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (both the same): -int negative_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int negative_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_COLOR_FILTERS; } // Return our description, localized: -char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { int mode_idx; @@ -164,8 +152,7 @@ char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, return (strdup(gettext_noop(negative_descs[which][mode_idx]))); } -static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b, - Uint8 * new_r, Uint8 * new_g, Uint8 * new_b) +static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b, Uint8 * new_r, Uint8 * new_g, Uint8 * new_b) { float h, s, v, new_h; magic_api *api = (magic_api *) ptr; @@ -189,8 +176,7 @@ static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b, } // Callback that does the negative color effect on a circle centered around x,y -static void do_negative(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_negative(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; Uint8 r, g, b, new_r, new_g, new_b; @@ -204,8 +190,7 @@ static void do_negative(void *ptr, int which, SDL_Surface * canvas, { SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b); negative_calc(api, which, r, g, b, &new_r, &new_g, &new_b); - api->putpixel(canvas, xx, yy, - SDL_MapRGB(canvas->format, new_r, new_g, new_b)); + api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, new_r, new_g, new_b)); } } } @@ -213,13 +198,12 @@ static void do_negative(void *ptr, int which, SDL_Surface * canvas, // Ask Tux Paint to call our 'do_negative()' callback over a line void negative_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) { SDL_LockSurface(last); SDL_LockSurface(canvas); - api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_negative); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_negative); if (ox > x) { @@ -250,8 +234,7 @@ void negative_drag(magic_api * api, int which, SDL_Surface * canvas, // Ask Tux Paint to call our 'do_negative()' callback at a single point void negative_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) negative_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -266,8 +249,7 @@ void negative_click(magic_api * api, int which, int mode, { SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b); negative_calc(api, which, r, g, b, &new_r, &new_g, &new_b); - api->putpixel(canvas, xx, yy, - SDL_MapRGB(canvas->format, new_r, new_g, new_b)); + api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, new_r, new_g, new_b)); } } @@ -285,8 +267,7 @@ void negative_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -298,38 +279,37 @@ void negative_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // We don't use colors -void negative_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) +void negative_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) { } // We don't use colors -int negative_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int negative_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void negative_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 negative_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 negative_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int negative_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT | MODE_FULLSCREEN); } -Uint8 negative_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { +Uint8 negative_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) +{ if (mode == MODE_PAINT) return 8; else @@ -341,7 +321,9 @@ Uint8 negative_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT return 4; } -void negative_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 negative_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) { negative_radius = size * 4; } diff --git a/magic/src/noise.c b/magic/src/noise.c index 63c20338e..9202165e8 100644 --- a/magic/src/noise.c +++ b/magic/src/noise.c @@ -70,8 +70,7 @@ const int noise_groups[noise_NUM_TOOLS] = { }; const char *noise_descs[noise_NUM_TOOLS][2] = { - {gettext_noop - ("Click and drag the mouse to add noise to parts of your picture."), + {gettext_noop("Click and drag the mouse to add noise to parts of your picture."), gettext_noop("Click to add noise to your entire picture."),}, }; @@ -81,15 +80,11 @@ SDL_Surface *noise_get_icon(magic_api * api, int which); char *noise_get_name(magic_api * api, int which); int noise_get_group(magic_api * api, int which); char *noise_get_description(magic_api * api, int which, int mode); -static void do_noise_pixel(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which); -static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_noise_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which); +static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void noise_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); void noise_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void noise_release(magic_api * api, int which, SDL_Surface * canvas, @@ -98,15 +93,14 @@ void noise_shutdown(magic_api * api); void noise_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int noise_requires_colors(magic_api * api, int which); -void noise_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void noise_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void noise_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void noise_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int noise_modes(magic_api * api, int which); int noise_get_tool_count(magic_api * api ATTRIBUTE_UNUSED); Uint8 noise_accepted_sizes(magic_api * api, int which, int mode); Uint8 noise_default_size(magic_api * api, int which, int mode); -void noise_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void noise_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 noise_api_version(void) @@ -124,8 +118,7 @@ int noise_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < noise_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - noise_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, noise_snd_filenames[i]); noise_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -141,8 +134,7 @@ SDL_Surface *noise_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - noise_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, noise_icon_filenames[which]); return (IMG_Load(fname)); } @@ -159,16 +151,14 @@ int noise_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *noise_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *noise_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(noise_descs[which][mode - 1]))); } //Do the effect for one pixel static void do_noise_pixel(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -176,22 +166,17 @@ static void do_noise_pixel(void *ptr, int which ATTRIBUTE_UNUSED, double temp2[3]; int k; - SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], - &temp[2]); + SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]); for (k = 0; k < 3; k++) { - temp2[k] = - clamp(0.0, (int) temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, - 255.0); + temp2[k] = clamp(0.0, (int)temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, 255.0); } - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); + api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); } // Do the effect for the full image -static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which) +static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which) { int x, y; @@ -205,8 +190,7 @@ static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, } //do the effect for the brush -static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; magic_api *api = (magic_api *) ptr; @@ -215,8 +199,7 @@ static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, { for (xx = x - noise_RADIUS; xx < x + noise_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, noise_RADIUS) - && !api->touched(xx, yy)) + if (api->in_circle(xx - x, yy - y, noise_RADIUS) && !api->touched(xx, yy)) { do_noise_pixel(api, which, canvas, last, xx, yy); } @@ -226,12 +209,10 @@ static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void noise_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_noise_brush); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_noise_brush); api->playsound(noise_snd_effect[which], (x * 255) / canvas->w, 255); @@ -258,8 +239,7 @@ void noise_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void noise_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) noise_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -279,8 +259,7 @@ void noise_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -300,27 +279,26 @@ void noise_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void noise_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) +void noise_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) { } // Use colors: -int noise_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int noise_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void noise_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 noise_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) { } @@ -343,7 +321,9 @@ Uint8 noise_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 4; } -void noise_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 noise_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) { noise_RADIUS = size * 4; } diff --git a/magic/src/perspective.c b/magic/src/perspective.c index f23480afa..87c57182c 100644 --- a/magic/src/perspective.c +++ b/magic/src/perspective.c @@ -51,8 +51,7 @@ static void perspective_preview(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, - int x, int y, SDL_Rect * update_rect, - float step); + int x, int y, SDL_Rect * update_rect, float step); Uint32 perspective_api_version(void); int perspective_init(magic_api * api, Uint32 disabled_features); int perspective_get_tool_count(magic_api * api); @@ -63,16 +62,13 @@ int perspective_get_group(magic_api * api, int which); char *perspective_get_description(magic_api * api, int which, int mode); void perspective_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); void perspective_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 perspective_release(magic_api * api, int which, - 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 perspective_shutdown(magic_api * api); @@ -81,24 +77,21 @@ void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas, int perspective_requires_colors(magic_api * api, int which); -void perspective_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void perspective_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); -void perspective_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void perspective_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int perspective_modes(magic_api * api, int which); int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, - int x, int y, int fill_edge, int fill_tile, int size, - Uint32 color); + int x, int y, int fill_edge, int fill_tile, int size, Uint32 color); -void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); Uint8 perspective_accepted_sizes(magic_api * api, int which, int mode); Uint8 perspective_default_size(magic_api * api, int which, int mode); -void perspective_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void perspective_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -115,8 +108,7 @@ int click_x, click_y; int latest_x, latest_y; int new_w, new_h, old_h, sound_h; -int perspective_average_r, perspective_average_g, perspective_average_b, - perspective_average_count; +int perspective_average_r, perspective_average_g, perspective_average_b, perspective_average_count; Uint32 pixel_average, black, white; int otop_left_x, otop_left_y, otop_right_x, otop_right_y; @@ -178,19 +170,15 @@ const char *perspective_names[perspective_NUM_TOOLS] = { }; const char *perspective_descs[perspective_NUM_TOOLS] = { - gettext_noop - ("Click on the corners and drag where you want to stretch the picture."), + gettext_noop("Click on the corners and drag where you want to stretch the picture."), gettext_noop("Click to turn your picture into 2-by-2 panels."), - gettext_noop - ("Click and drag up to zoom in the picture. Drag down to zoom out and tile the picture."), + gettext_noop("Click and drag up to zoom in the picture. Drag down to zoom out and tile the picture."), - gettext_noop - ("Click and drag up to zoom in or drag down to zoom out the picture."), + gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."), - gettext_noop - ("Click and drag up to rush in or drag down to rush out the picture."), + gettext_noop("Click and drag up to rush in or drag down to rush out the picture."), }; Uint32 perspective_api_version(void) @@ -206,8 +194,7 @@ int perspective_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i <= perspective_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - perspective_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, perspective_snd_filenames[i]); perspective_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -223,8 +210,7 @@ SDL_Surface *perspective_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - perspective_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, perspective_icon_filenames[which]); return (IMG_Load(fname)); } @@ -235,15 +221,13 @@ char *perspective_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (the same): -int perspective_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int perspective_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } // Return our descriptions, localized: -char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { return (strdup(gettext_noop(perspective_descs[which]))); } @@ -252,8 +236,7 @@ char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, // Affect the canvas on drag: void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, - SDL_Rect * update_rect) + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { if (canvas_back == NULL) return; @@ -302,8 +285,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, /* Draw a square and the current shape relative to it as a visual reference */ /* square */ - api->line(api, which, canvas, last, otop_left_x, otop_left_y, - otop_right_x, otop_right_y, 1, perspective_line); + api->line(api, which, canvas, last, otop_left_x, otop_left_y, otop_right_x, otop_right_y, 1, perspective_line); api->line(api, which, canvas, last, otop_left_x, otop_left_y, obottom_left_x, obottom_left_y, 1, perspective_line); api->line(api, which, canvas, last, obottom_left_x, obottom_left_y, @@ -312,10 +294,8 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, otop_right_x, otop_right_y, 1, perspective_line); /* shape */ - api->line(api, which, canvas, last, top_left_x, top_left_y, top_right_x, - top_right_y, 1, perspective_line); - api->line(api, which, canvas, last, top_left_x, top_left_y, - bottom_left_x, bottom_left_y, 1, perspective_line); + api->line(api, which, canvas, last, top_left_x, top_left_y, top_right_x, top_right_y, 1, perspective_line); + api->line(api, which, canvas, last, top_left_x, top_left_y, bottom_left_x, bottom_left_y, 1, perspective_line); api->line(api, which, canvas, last, bottom_left_x, bottom_left_y, bottom_right_x, bottom_right_y, 1, perspective_line); api->line(api, which, canvas, last, bottom_right_x, bottom_right_y, @@ -324,8 +304,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, - api->playsound(perspective_snd_effect[which], (x * 255) / canvas->w, - 255); + api->playsound(perspective_snd_effect[which], (x * 255) / canvas->w, 255); } break; case TOOL_ZOOM: @@ -340,9 +319,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, update_rect->w = canvas->w; update_rect->h = canvas->h; - SDL_FillRect(canvas, update_rect, - SDL_MapRGB(canvas->format, perspective_r, perspective_g, - perspective_b)); + SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b)); } new_h = max(1, old_h + click_y - y); @@ -381,8 +358,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void perspective_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) { click_x = x; click_y = y; @@ -482,8 +458,7 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on release: void perspective_release(magic_api * api, int which, - 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 (canvas_back == NULL) return; @@ -496,9 +471,7 @@ void perspective_release(magic_api * api, int which, update_rect->h = canvas->h; if (which == TOOL_ZOOM || which == TOOL_PERSPECTIVE) - SDL_FillRect(canvas, update_rect, - SDL_MapRGB(canvas->format, perspective_r, perspective_g, - perspective_b)); + SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b)); if (which == TOOL_PERSPECTIVE) { @@ -508,7 +481,7 @@ void perspective_release(magic_api * api, int which, { int h1, h2, w, h, hh, dx1, dy1; SDL_Surface *scaled_surf; - SDL_Surface * aux1; + SDL_Surface *aux1; if (new_h == canvas->h || new_h == 0) { @@ -536,9 +509,10 @@ void perspective_release(magic_api * api, int which, aux1 = api->scale(last, last->w, last->h, 0); for (h = 0; h < h2 - h1; h++) + { + if (h % 10 == 0) { - if (h % 10 == 0) { - api->update_progress_bar(); + api->update_progress_bar(); } hh = h2 - h; w = canvas->w * hh / canvas->h; @@ -546,67 +520,68 @@ void perspective_release(magic_api * api, int which, dx1 = (canvas->w - scaled_surf->w) / 2; dy1 = (canvas->h - scaled_surf->h) / 2; SDL_Rect rrr; + rrr.x = dx1; rrr.y = dy1; rrr.w = dx1 + scaled_surf->w; rrr.h = dy1 + scaled_surf->h; - SDL_SetSurfaceBlendMode( scaled_surf, SDL_BLENDMODE_BLEND); - SDL_SetSurfaceAlphaMod(scaled_surf,24); + SDL_SetSurfaceBlendMode(scaled_surf, SDL_BLENDMODE_BLEND); + SDL_SetSurfaceAlphaMod(scaled_surf, 24); SDL_BlitSurface(scaled_surf, NULL, aux1, &rrr); SDL_FreeSurface(scaled_surf); - } + } SDL_BlitSurface(aux1, NULL, canvas, NULL); SDL_FreeSurface(aux1); /* - for (h = 0; h < (h2 - h1); h++) - { - if ((h / 2) % 10 == 0) - api->update_progress_bar(); + for (h = 0; h < (h2 - h1); h++) + { + if ((h / 2) % 10 == 0) + api->update_progress_bar(); -// if (new_h < canvas->h) - hh = h2 - h; -// else -// hh = new_h + h; + // if (new_h < canvas->h) + hh = h2 - h; + // else + // hh = new_h + h; - w = canvas->w * hh / canvas->h; - scaled_surf = api->scale(last, w, hh, 0); + w = canvas->w * hh / canvas->h; + scaled_surf = api->scale(last, w, hh, 0); - dx1 = (canvas->w - scaled_surf->w) / 2; - dy1 = (canvas->h - scaled_surf->h) / 2; + dx1 = (canvas->w - scaled_surf->w) / 2; + dy1 = (canvas->h - scaled_surf->h) / 2; - for (y = 0; y < scaled_surf->h; y++) - { - if (dy1 + y >= 0 && dy1 + y < canvas->h) - { - for (x = 0; x < scaled_surf->w; x++) - { - if (dx1 + x >= 0 && dx1 + x < canvas->w) - { - SDL_GetRGB(api->getpixel(scaled_surf, x, y), - scaled_surf->format, &r1, &g1, &b1); - SDL_GetRGB(api->getpixel(canvas, dx1 + x, dy1 + y), - canvas->format, &r2, &g2, &b2); - pct = (float) ((float) h / ((float) h2 - (float) h1)); -// if (new_h > canvas->h) -// pct = 1.0 - pct; - r = - api->linear_to_sRGB((api->sRGB_to_linear(r1) * (1.0 - pct)) + - (api->sRGB_to_linear(r2) * (pct))); - g = - api->linear_to_sRGB((api->sRGB_to_linear(g1) * (1.0 - pct)) + - (api->sRGB_to_linear(g2) * (pct))); - b = - api->linear_to_sRGB((api->sRGB_to_linear(b1) * (1.0 - pct)) + - (api->sRGB_to_linear(b2) * (pct))); + for (y = 0; y < scaled_surf->h; y++) + { + if (dy1 + y >= 0 && dy1 + y < canvas->h) + { + for (x = 0; x < scaled_surf->w; x++) + { + if (dx1 + x >= 0 && dx1 + x < canvas->w) + { + SDL_GetRGB(api->getpixel(scaled_surf, x, y), + scaled_surf->format, &r1, &g1, &b1); + SDL_GetRGB(api->getpixel(canvas, dx1 + x, dy1 + y), + canvas->format, &r2, &g2, &b2); + pct = (float) ((float) h / ((float) h2 - (float) h1)); + // if (new_h > canvas->h) + // pct = 1.0 - pct; + r = + api->linear_to_sRGB((api->sRGB_to_linear(r1) * (1.0 - pct)) + + (api->sRGB_to_linear(r2) * (pct))); + g = + api->linear_to_sRGB((api->sRGB_to_linear(g1) * (1.0 - pct)) + + (api->sRGB_to_linear(g2) * (pct))); + b = + api->linear_to_sRGB((api->sRGB_to_linear(b1) * (1.0 - pct)) + + (api->sRGB_to_linear(b2) * (pct))); - api->putpixel(canvas, dx1 + x, dy1 + y, - SDL_MapRGB(canvas->format, r, g, b)); - } - } - } - } - }*/ + api->putpixel(canvas, dx1 + x, dy1 + y, + SDL_MapRGB(canvas->format, r, g, b)); + } + } + } + } + } */ update_rect->x = 0; update_rect->y = 0; @@ -623,9 +598,7 @@ void perspective_release(magic_api * api, int which, update_rect->h = canvas->h; if (which == TOOL_ZOOM) - SDL_FillRect(canvas, update_rect, - SDL_MapRGB(canvas->format, perspective_r, perspective_g, - perspective_b)); + SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b)); if (new_h < canvas->h) @@ -670,9 +643,7 @@ void perspective_release(magic_api * api, int which, aux_w, aux_h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); SDL_BlitSurface(canvas_back, update_rect, aux_surf, NULL); scaled_surf = api->scale(aux_surf, canvas->w, canvas->h, 0); @@ -691,8 +662,7 @@ void perspective_release(magic_api * api, int which, void perspective_preview(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect, float step) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect, float step) { float i, j; float ax, ay, bx, by, dx, dy; @@ -708,47 +678,42 @@ void perspective_preview(magic_api * api, int which, update_rect->h = canvas->h; if (which == TOOL_ZOOM) - SDL_FillRect(canvas, update_rect, - SDL_MapRGB(canvas->format, perspective_r, perspective_g, - perspective_b)); + SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b)); else if (which == TOOL_TILEZOOM || which == TOOL_RUSH) - SDL_FillRect(canvas, update_rect, - SDL_MapRGB(canvas->format, 128, 128, 128)); + SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, 128, 128, 128)); ox_distance = otop_right_x - otop_left_x; oy_distance = obottom_left_y - otop_left_y; - top_advc_x = (float) (top_right_x - top_left_x) / ox_distance; - top_advc_y = (float) (top_right_y - top_left_y) / ox_distance; + top_advc_x = (float)(top_right_x - top_left_x) / ox_distance; + top_advc_y = (float)(top_right_y - top_left_y) / ox_distance; - left_advc_x = (float) (bottom_left_x - top_left_x) / oy_distance; - left_advc_y = (float) (bottom_left_y - top_left_y) / oy_distance; + left_advc_x = (float)(bottom_left_x - top_left_x) / oy_distance; + left_advc_y = (float)(bottom_left_y - top_left_y) / oy_distance; - right_advc_x = (float) (bottom_right_x - top_right_x) / oy_distance; - right_advc_y = (float) (bottom_right_y - top_right_y) / oy_distance; + right_advc_x = (float)(bottom_right_x - top_right_x) / oy_distance; + right_advc_y = (float)(bottom_right_y - top_right_y) / oy_distance; - bottom_advc_x = (float) (bottom_right_x - bottom_left_x) / ox_distance; - bottom_advc_y = (float) (bottom_right_y - bottom_left_y) / ox_distance; + bottom_advc_x = (float)(bottom_right_x - bottom_left_x) / ox_distance; + bottom_advc_y = (float)(bottom_right_y - bottom_left_y) / ox_distance; center_ofset_x = (otop_left_x - top_left_x) * 2; center_ofset_y = (otop_left_y - top_left_y) * 2; for (i = 0; i < canvas->w; i += step) { - ax = (float) top_advc_x *i; - ay = (float) top_advc_y *i; - bx = (float) bottom_advc_x *i + (bottom_left_x - top_left_x) * 2; - by = (float) bottom_advc_y *i + (bottom_left_y - top_left_y) * 2; + ax = (float)top_advc_x *i; + ay = (float)top_advc_y *i; + bx = (float)bottom_advc_x *i + (bottom_left_x - top_left_x) * 2; + by = (float)bottom_advc_y *i + (bottom_left_y - top_left_y) * 2; for (j = 0; j < canvas->h; j += step) { - dx = (float) (bx - ax) / canvas->h * j; - dy = (float) (by - ay) / canvas->h * j; + dx = (float)(bx - ax) / canvas->h * j; + dy = (float)(by - ay) / canvas->h * j; - api->putpixel(canvas, ax + dx - center_ofset_x, - ay + dy - center_ofset_y, api->getpixel(canvas_back, i, - j)); + api->putpixel(canvas, ax + dx - center_ofset_x, ay + dy - center_ofset_y, api->getpixel(canvas_back, i, j)); } } @@ -800,7 +765,8 @@ void perspective_shutdown(magic_api * api ATTRIBUTE_UNUSED) void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect) { - if (r != perspective_r || g != perspective_g || b != perspective_b) { + if (r != perspective_r || g != perspective_g || b != perspective_b) + { perspective_r = r; perspective_g = g; perspective_b = b; @@ -818,8 +784,7 @@ int perspective_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which) } void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { Uint32 amask; @@ -829,29 +794,26 @@ void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED, top_left_x = otop_left_x = bottom_left_x = obottom_left_x = canvas->w / 4; top_left_y = otop_left_y = top_right_y = otop_right_y = canvas->h / 4; - top_right_x = otop_right_x = bottom_right_x = obottom_right_x = - canvas->w - otop_left_x; + top_right_x = otop_right_x = bottom_right_x = obottom_right_x = canvas->w - otop_left_x; - bottom_left_y = obottom_left_y = bottom_right_y = obottom_right_y = - canvas->h - otop_left_y; + bottom_left_y = obottom_left_y = bottom_right_y = obottom_right_y = canvas->h - otop_left_y; black = SDL_MapRGBA(canvas->format, 0, 0, 0, 0); white = SDL_MapRGBA(canvas->format, 255, 255, 255, 0); - amask = - ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); + amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask); - if (canvas_back == NULL) { + if (canvas_back == NULL) + { canvas_back = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, amask); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask); } - if (canvas_back == NULL) { + if (canvas_back == NULL) + { fprintf(stderr, "perspective cannot create background canvas!\n"); return; } @@ -860,11 +822,10 @@ void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED, } void perspective_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) { - if (canvas_back != NULL) { + if (canvas_back != NULL) + { SDL_FreeSurface(canvas_back); canvas_back = NULL; } @@ -883,8 +844,7 @@ int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which) } void perspective_line(void *ptr_to_api, 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_to_api; @@ -898,7 +858,8 @@ void perspective_line(void *ptr_to_api, int which ATTRIBUTE_UNUSED, } -Uint8 perspective_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 perspective_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } @@ -908,6 +869,8 @@ Uint8 perspective_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI return 0; } -void perspective_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 perspective_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) { } diff --git a/magic/src/pixels.c b/magic/src/pixels.c index 6359cf0e4..2361cc52f 100644 --- a/magic/src/pixels.c +++ b/magic/src/pixels.c @@ -58,8 +58,7 @@ char *pixels_get_name(magic_api * api, int which); int pixels_get_group(magic_api * api, int which); char *pixels_get_description(magic_api * api, int which, int mode); void pixels_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); void pixels_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void pixels_release(magic_api * api, int which, SDL_Surface * canvas, @@ -68,14 +67,13 @@ void pixels_shutdown(magic_api * api); void pixels_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int pixels_requires_colors(magic_api * api, int which); -void pixels_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void pixels_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void pixels_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void pixels_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int pixels_modes(magic_api * api, int which); Uint8 pixels_accepted_sizes(magic_api * api, int which, int mode); Uint8 pixels_default_size(magic_api * api, int which, int mode); -void pixels_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void pixels_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // No setup required: @@ -83,8 +81,7 @@ int pixels_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/pixels.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/pixels.ogg", api->data_directory); pixel_snd = Mix_LoadWAV(fname); return (1); @@ -106,30 +103,25 @@ SDL_Surface *pixels_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/pixels.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/pixels.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *pixels_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *pixels_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Pixels"))); } // Return our group (both the same): -int pixels_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int pixels_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Click and drag to draw large pixels."))); @@ -139,8 +131,7 @@ char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect: static void do_pixels(void *ptr ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { SDL_Rect dest; @@ -149,16 +140,14 @@ static void do_pixels(void *ptr ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, dest.w = pixel_size; dest.h = pixel_size; - SDL_FillRect(canvas, &dest, - SDL_MapRGB(canvas->format, pixels_r, pixels_g, pixels_b)); + SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, pixels_r, pixels_g, pixels_b)); } // Affect the canvas on drag: void pixels_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_pixels); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_pixels); if (ox > x) { @@ -190,8 +179,7 @@ void pixels_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void pixels_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) { pixels_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -199,8 +187,7 @@ void pixels_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void pixels_release(magic_api * api, 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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { api->stopsound(); } @@ -213,8 +200,9 @@ void pixels_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void pixels_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 pixels_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) { pixels_r = r; pixels_g = g; @@ -222,21 +210,18 @@ void pixels_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS } // Use colors: -int pixels_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int pixels_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } void pixels_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 pixels_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) { } @@ -256,7 +241,9 @@ Uint8 pixels_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 1; } -void pixels_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED) +void pixels_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { int canv_area_scale; diff --git a/magic/src/puzzle.c b/magic/src/puzzle.c index 6d99aa8a5..cf2390b9c 100644 --- a/magic/src/puzzle.c +++ b/magic/src/puzzle.c @@ -57,30 +57,25 @@ char *puzzle_get_name(magic_api * api, int which); int puzzle_get_group(magic_api * api, int which); char *puzzle_get_description(magic_api * api, int which, int mode); void puzzle_release(magic_api * api, int which, - 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 puzzle_shutdown(magic_api * api); void puzzle_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int puzzle_requires_colors(magic_api * api, int which); -void puzzle_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void puzzle_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void puzzle_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void puzzle_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int puzzle_modes(magic_api * api, int which); -static void puzzle_draw(void *ptr, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +static void puzzle_draw(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void puzzle_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); void puzzle_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); int gcd(int a, int b); Uint8 puzzle_accepted_sizes(magic_api * api, int which, int mode); Uint8 puzzle_default_size(magic_api * api, int which, int mode); -void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 puzzle_api_version(void) { @@ -91,8 +86,7 @@ int puzzle_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/puzzle.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/puzzle.wav", api->data_directory); puzzle_snd = Mix_LoadWAV(fname); return 1; @@ -107,32 +101,26 @@ SDL_Surface *puzzle_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/puzzle.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/puzzle.png", api->data_directory); return (IMG_Load(fname)); } -char *puzzle_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *puzzle_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Puzzle"))); } -int puzzle_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int puzzle_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } -char *puzzle_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *puzzle_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return - strdup(gettext_noop - ("Click the part of your picture where would you like a puzzle.")); + return strdup(gettext_noop("Click the part of your picture where would you like a puzzle.")); return strdup(gettext_noop("Click to make a puzzle in fullscreen mode.")); } @@ -140,8 +128,7 @@ void puzzle_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -151,13 +138,14 @@ void puzzle_shutdown(magic_api * api ATTRIBUTE_UNUSED) Mix_FreeChunk(puzzle_snd); } -void puzzle_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) +void puzzle_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) { } -int puzzle_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int puzzle_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -170,22 +158,19 @@ int gcd(int a, int b) //greatest common divisor } void puzzle_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { puzzle_gcd = RATIO * gcd(canvas->w, canvas->h); - rects_w = (unsigned int) canvas->w / puzzle_gcd; - rects_h = (unsigned int) canvas->h / puzzle_gcd; + rects_w = (unsigned int)canvas->w / puzzle_gcd; + rects_h = (unsigned int)canvas->h / puzzle_gcd; canvas_backup = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); } void puzzle_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) { SDL_FreeSurface(canvas_backup); canvas_backup = NULL; @@ -197,8 +182,7 @@ int puzzle_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) } static void puzzle_draw(void *ptr, int which_tool 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) { @@ -258,20 +242,14 @@ static void puzzle_draw(void *ptr, int which_tool ATTRIBUTE_UNUSED, void puzzle_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, - SDL_Rect * update_rect) + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { - puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, - y - puzzle_gcd / 2); + puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y - puzzle_gcd / 2); - puzzle_draw(api, which, canvas, last, x - 1.5 * puzzle_gcd / 2, - y - puzzle_gcd / 2); - puzzle_draw(api, which, canvas, last, x + 0.5 * puzzle_gcd, - y - puzzle_gcd / 2); - puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, - y - 1.5 * puzzle_gcd); - puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, - y + 0.5 * puzzle_gcd); + puzzle_draw(api, which, canvas, last, x - 1.5 * puzzle_gcd / 2, y - puzzle_gcd / 2); + puzzle_draw(api, which, canvas, last, x + 0.5 * puzzle_gcd, y - puzzle_gcd / 2); + puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y - 1.5 * puzzle_gcd); + puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y + 0.5 * puzzle_gcd); update_rect->x = 0; update_rect->y = 0; @@ -280,8 +258,7 @@ void puzzle_drag(magic_api * api, int which, SDL_Surface * canvas, } void puzzle_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) { puzzle_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -297,9 +274,9 @@ Uint8 puzzle_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 4; } -void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED) +void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, + Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { RATIO = size + 1; puzzle_switchin(api, which, mode, canvas); } - diff --git a/magic/src/rails.c b/magic/src/rails.c index ce6300a4f..d7eeab3e2 100644 --- a/magic/src/rails.c +++ b/magic/src/rails.c @@ -60,37 +60,30 @@ int rails_get_group(magic_api * api, int which); char *rails_get_description(magic_api * api, int which, int mode); int rails_requires_colors(magic_api * api, int which); void rails_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 rails_shutdown(magic_api * api); -void rails_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void rails_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void rails_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void rails_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); inline unsigned int rails_get_segment(int x, int y); + #define POINT_TYPE typeof(((SDL_Rect *)NULL)->x) -inline void rails_extract_coords_from_segment(unsigned int segment, - POINT_TYPE * x, POINT_TYPE * y); +inline void rails_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y); static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src); static void rails_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src); -static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, - unsigned int direction); +static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, unsigned int direction); void rails_click(magic_api * api, int which, int mode, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); static Uint8 rails_select_image(Uint16 segment); static void rails_draw(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - unsigned int segment); + SDL_Surface * last, int x, int y, unsigned int segment); -static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void rails_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); Uint8 rails_accepted_sizes(magic_api * api, int which, int mode); Uint8 rails_default_size(magic_api * api, int which, int mode); -void rails_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void rails_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 rails_api_version(void) { @@ -102,8 +95,10 @@ int rails_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) return (MODE_PAINT); } -void rails_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) +void rails_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) { } @@ -112,19 +107,15 @@ int rails_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) char fname[1024]; Uint8 i; //is always < 3, so Uint8 seems to be a good idea - rails_images = (char **) malloc(sizeof(char *) * 4); + rails_images = (char **)malloc(sizeof(char *) * 4); for (i = 0; i < 4; i++) - rails_images[i] = (char *) malloc(sizeof(char) * 1024); + rails_images[i] = (char *)malloc(sizeof(char) * 1024); - snprintf(rails_images[0], 1024 * sizeof(char), - "%simages/magic/rails_one.png", api->data_directory); - snprintf(rails_images[1], 1024 * sizeof(char), - "%simages/magic/rails_three.png", api->data_directory); - snprintf(rails_images[2], 1024 * sizeof(char), - "%simages/magic/rails_four.png", api->data_directory); - snprintf(rails_images[3], 1024 * sizeof(char), - "%simages/magic/rails_corner.png", api->data_directory); + snprintf(rails_images[0], 1024 * sizeof(char), "%simages/magic/rails_one.png", api->data_directory); + snprintf(rails_images[1], 1024 * sizeof(char), "%simages/magic/rails_three.png", api->data_directory); + snprintf(rails_images[2], 1024 * sizeof(char), "%simages/magic/rails_four.png", api->data_directory); + snprintf(rails_images[3], 1024 * sizeof(char), "%simages/magic/rails_corner.png", api->data_directory); rails_one = IMG_Load(rails_images[0]); rails_three = IMG_Load(rails_images[1]); @@ -134,8 +125,7 @@ int rails_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) img_w = rails_one->w; img_h = rails_one->h; - snprintf(fname, sizeof(fname), "%ssounds/magic/rails.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/rails.wav", api->data_directory); rails_snd = Mix_LoadWAV(fname); return (1); @@ -150,35 +140,27 @@ SDL_Surface *rails_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/rails.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rails.png", api->data_directory); return (IMG_Load(fname)); } -char *rails_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *rails_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Rails")); } -int rails_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rails_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } -char *rails_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *rails_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext_noop - ("Click and drag to draw train track rails on your picture.")); + return strdup(gettext_noop("Click and drag to draw train track rails on your picture.")); } -int rails_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rails_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -187,8 +169,7 @@ void rails_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) { } @@ -212,28 +193,24 @@ void rails_shutdown(magic_api * api ATTRIBUTE_UNUSED) } void rails_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { //we've to compute the quantity of segments in each direction canvas_backup = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); SDL_BlitSurface(canvas, NULL, canvas_backup, NULL); rails_segments_x = rails_math_ceil(canvas->w, img_w); rails_segments_y = rails_math_ceil(canvas->h, img_h); //status_of_segments[0] will not be used, we write in rails_status_of_segments[1 to segments_x*segments_y] - rails_status_of_segments = - (Uint8 *) calloc(rails_segments_x * rails_segments_y + 1, sizeof(Uint8)); + rails_status_of_segments = (Uint8 *) calloc(rails_segments_x * rails_segments_y + 1, sizeof(Uint8)); } void rails_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) { if (rails_status_of_segments != NULL) { @@ -248,7 +225,7 @@ inline int rails_math_ceil(int x, int y) { int temp; - temp = (int) x / y; + temp = (int)x / y; if (x % y) return temp + 1; @@ -269,11 +246,10 @@ inline unsigned int rails_get_segment(int x, int y) } -inline void rails_extract_coords_from_segment(unsigned int segment, - POINT_TYPE * x, POINT_TYPE * y) +inline void rails_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y) { //extracts the coords of the beginning and the segment *x = ((segment % rails_segments_x) - 1) * img_w; //useful to set update_rect as small as possible - *y = (int) (segment / rails_segments_x) * img_h; + *y = (int)(segment / rails_segments_x) * img_h; } static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src) @@ -296,8 +272,7 @@ static void rails_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src) api->putpixel(dest, x, y, api->getpixel(src, y, x)); } -static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, - unsigned int direction) +static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, unsigned int direction) //src and dest must have same size { magic_api *api = (magic_api *) ptr; @@ -319,8 +294,7 @@ static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, } void rails_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) { rails_segment_modified_last = 0; rails_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); @@ -331,8 +305,7 @@ static Uint8 rails_select_image(Uint16 segment) int take_up, take_down; int val_up, val_down, val_left, val_right; int from_top = 0, from_bottom = 0, from_left = 0, from_right = 0; - int from_top_right = 0, from_top_left = 0, from_bottom_right = - 0, from_bottom_left = 0; + int from_top_right = 0, from_top_left = 0, from_bottom_right = 0, from_bottom_left = 0; int TOP = 0, BOTTOM = 0, LEFT = 0, RIGHT = 0; //Checking from were we come... @@ -387,7 +360,7 @@ static Uint8 rails_select_image(Uint16 segment) val_up = rails_status_of_segments[take_up]; take_down = segment + rails_segments_x; - if (take_down > (signed) (rails_segments_x * rails_segments_y)) + if (take_down > (signed)(rails_segments_x * rails_segments_y)) val_down = SEG_NONE; else val_down = rails_status_of_segments[take_down]; @@ -446,8 +419,7 @@ static Uint8 rails_select_image(Uint16 segment) static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED, ATTRIBUTE_UNUSED SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, - int y ATTRIBUTE_UNUSED, unsigned int segment) + SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y ATTRIBUTE_UNUSED, unsigned int segment) { magic_api *api = (magic_api *) ptr; SDL_Surface *result, *temp; @@ -458,8 +430,7 @@ static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED, if (segment > rails_segments_x * rails_segments_y) return; //modification_rect.x and modification_rect.y are set by function - rails_extract_coords_from_segment(segment, &modification_rect.x, - &modification_rect.y); + rails_extract_coords_from_segment(segment, &modification_rect.x, &modification_rect.y); modification_rect.h = img_w; modification_rect.w = img_h; @@ -553,8 +524,7 @@ static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED, api->playsound(rails_snd, (x * 255) / canvas->w, 255); } -static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { rails_segment_modified = rails_get_segment(x, y); @@ -563,18 +533,15 @@ static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, return; if (rails_segment_modified > 0) { - rails_draw((void *) ptr, which, canvas, last, x, y, - rails_segment_modified); + rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified); } if (rails_segment_modified_last > 0) - rails_draw((void *) ptr, which, canvas, last, x, y, - rails_segment_modified_last); + rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified_last); if (rails_segment_to_add > 0) { - rails_draw((void *) ptr, which, canvas, last, x, y, rails_segment_to_add); - rails_draw((void *) ptr, which, canvas, last, x, y, - rails_segment_modified_last); + rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_to_add); + rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified_last); rails_segment_to_add = 0; } if (rails_segment_modified > 0) @@ -582,18 +549,15 @@ static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, } void rails_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) { int start_x, end_x, start_y, end_y, segment_start, segment_end, w, h; // avoiding to write out of the canvas if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w) - && (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0) - && ((signed) ox > 0) && ((signed) oy > 0)) + && (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0)) { - api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, - rails_draw_wrapper); + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, rails_draw_wrapper); start_x = min(ox, x); end_x = max(ox, x); @@ -604,9 +568,9 @@ void rails_drag(magic_api * api, int which, SDL_Surface * canvas, segment_end = rails_get_segment(end_x + img_w, end_y + img_h); x = ((segment_start % rails_segments_x) - 1) * img_w; - y = (int) (segment_start / rails_segments_x) * img_h; + y = (int)(segment_start / rails_segments_x) * img_h; w = ((segment_end % rails_segments_x) - 1) * img_w - x + img_w; - h = (int) (segment_end / rails_segments_x) * img_h - y + img_h; + h = (int)(segment_end / rails_segments_x) * img_h - y + img_h; update_rect->x = x; update_rect->y = y; @@ -627,6 +591,8 @@ Uint8 rails_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 0; } -void rails_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 rails_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) { } diff --git a/magic/src/rain.c b/magic/src/rain.c index c6a394665..53a570802 100644 --- a/magic/src/rain.c +++ b/magic/src/rain.c @@ -42,8 +42,7 @@ #define gettext_noop(String) String #endif -void rain_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, - SDL_Rect *); +void rain_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); static int rain_SIZE = 30; static int rain_AMOUNT = 200; @@ -84,13 +83,10 @@ SDL_Surface *rain_get_icon(magic_api * api, int which); char *rain_get_name(magic_api * api, int which); int rain_get_group(magic_api * api, int which); char *rain_get_description(magic_api * api, int which, int mode); -static void do_rain_drop(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_rain_drop(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void rain_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); void rain_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void rain_release(magic_api * api, int which, SDL_Surface * canvas, @@ -99,14 +95,13 @@ void rain_shutdown(magic_api * api); void rain_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int rain_requires_colors(magic_api * api, int which); -void rain_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void rain_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void rain_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void rain_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int rain_modes(magic_api * api, int which); Uint8 rain_accepted_sizes(magic_api * api, int which, int mode); Uint8 rain_default_size(magic_api * api, int which, int mode); -void rain_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void rain_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 rain_api_version(void) @@ -117,7 +112,7 @@ Uint32 rain_api_version(void) //Checks if a a pixel is inside a raindrop shape centered on the origin static int rain_inRainShape(double x, double y, double r) { - if (sqrt(x * x + y * y) < (r * pow(cos(atan2(x, y)), (float) (rain_SIZE / 3.0)))) + if (sqrt(x * x + y * y) < (r * pow(cos(atan2(x, y)), (float)(rain_SIZE / 3.0)))) { return 1; } @@ -133,8 +128,7 @@ int rain_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) //Load sounds for (i = 0; i < rain_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - rain_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, rain_snd_filenames[i]); rain_snd_effect[i] = Mix_LoadWAV(fname); } @@ -151,8 +145,7 @@ SDL_Surface *rain_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - rain_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, rain_icon_filenames[which]); return (IMG_Load(fname)); } @@ -169,16 +162,14 @@ int rain_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *rain_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *rain_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(rain_descs[which][mode - 1]))); } // Do the effect: static void do_rain_drop(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -195,17 +186,14 @@ static void do_rain_drop(void *ptr, int which ATTRIBUTE_UNUSED, //api->hsvtorgb(h, s, rain_weights[(yy-y)*((rain_SIZE*2) -1)+(xx-x)], &r, &g, &b); SDL_GetRGB(api->getpixel(canvas, xx, yy), canvas->format, &r, &g, &b); api->putpixel(canvas, xx, yy, - SDL_MapRGB(canvas->format, clamp(0, r - 50, 255), - clamp(0, g - 50, 255), clamp(0, b + 200, - 255))); + SDL_MapRGB(canvas->format, clamp(0, r - 50, 255), clamp(0, g - 50, 255), clamp(0, b + 200, 255))); } } } } -static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; SDL_Rect rect; @@ -213,17 +201,15 @@ static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, if (rand() % 10 == 0) { rain_click(api, which, MODE_PAINT, canvas, last, - x + (rand() % rain_SIZE * 2) - rain_SIZE, - y + (rand() % rain_SIZE * 2) - rain_SIZE, &rect); + x + (rand() % rain_SIZE * 2) - rain_SIZE, y + (rand() % rain_SIZE * 2) - rain_SIZE, &rect); } } // Affect the canvas on drag: void rain_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, rain_linecb); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, rain_linecb); if (ox > x) { @@ -248,8 +234,7 @@ void rain_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void rain_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) @@ -270,8 +255,7 @@ void rain_click(magic_api * api, int which, int mode, for (i = 0; i < rain_AMOUNT; i++) { - do_rain_drop(api, which, canvas, last, rand() % canvas->w, - rand() % canvas->h); + do_rain_drop(api, which, canvas, last, rand() % canvas->w, rand() % canvas->h); } update_rect->x = 0; @@ -288,8 +272,7 @@ void rain_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) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -310,27 +293,25 @@ void rain_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void rain_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 * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, + Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } // Use colors: -int rain_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rain_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void rain_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 rain_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) { } @@ -351,7 +332,9 @@ Uint8 rain_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 2; } -void rain_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 rain_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) { rain_SIZE = size * 15; rain_AMOUNT = 400 / size; diff --git a/magic/src/rainbow.c b/magic/src/rainbow.c index 559896bff..f5fd4774d 100644 --- a/magic/src/rainbow.c +++ b/magic/src/rainbow.c @@ -77,34 +77,29 @@ SDL_Surface *rainbow_get_icon(magic_api * api, int which); char *rainbow_get_name(magic_api * api, int which); int rainbow_get_group(magic_api * api, int which); char *rainbow_get_description(magic_api * api, int which, int mode); -static void rainbow_linecb(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void rainbow_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void rainbow_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); void rainbow_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 rainbow_release(magic_api * api, int which, - 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 rainbow_shutdown(magic_api * api); void rainbow_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int rainbow_requires_colors(magic_api * api, int which); -void rainbow_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void rainbow_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void rainbow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void rainbow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int rainbow_modes(magic_api * api, int which); Uint8 rainbow_accepted_sizes(magic_api * api, int which, int mode); Uint8 rainbow_default_size(magic_api * api, int which, int mode); -void rainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void rainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 rainbow_api_version(void) @@ -121,8 +116,7 @@ int rainbow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) rainbow_color = 0; rainbow_mix = 0; - snprintf(fname, sizeof(fname), "%ssounds/magic/rainbow.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/rainbow.wav", api->data_directory); rainbow_snd = Mix_LoadWAV(fname); return (1); @@ -139,15 +133,13 @@ SDL_Surface *rainbow_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { if (which == 0) { @@ -160,16 +152,13 @@ char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, } // Return our group: -int rainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PAINTING; } // Return our descriptions, localized: -char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("You can draw in rainbow colors!"))); } @@ -177,8 +166,7 @@ char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect: static void rainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -197,8 +185,7 @@ static void rainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void rainbow_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) { Uint8 r1, g1, b1, r2, g2, b2; int rc_tmp; @@ -232,11 +219,9 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas, (r2 * rainbow_mix)) / MIX_MAX, ((g1 * (MIX_MAX - rainbow_mix)) + (g2 * rainbow_mix)) / MIX_MAX, - ((b1 * (MIX_MAX - rainbow_mix)) + - (b2 * rainbow_mix)) / MIX_MAX); + ((b1 * (MIX_MAX - rainbow_mix)) + (b2 * rainbow_mix)) / MIX_MAX); - api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, - rainbow_linecb); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, rainbow_linecb); if (ox > x) { @@ -263,8 +248,7 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void rainbow_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) { rainbow_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -273,8 +257,7 @@ void rainbow_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -286,32 +269,30 @@ void rainbow_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void rainbow_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) +void rainbow_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) { } // Use colors: -int rainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void rainbow_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 rainbow_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 rainbow_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int rainbow_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -327,7 +308,9 @@ Uint8 rainbow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 4; } -void rainbow_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 rainbow_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) { rainbow_radius = size * 4; } diff --git a/magic/src/realrainbow.c b/magic/src/realrainbow.c index 580d2e25b..b6bca3512 100644 --- a/magic/src/realrainbow.c +++ b/magic/src/realrainbow.c @@ -25,15 +25,12 @@ Mix_Chunk *realrainbow_snd; int realrainbow_x1, realrainbow_y1, realrainbow_x2, realrainbow_y2; SDL_Rect realrainbow_rect; SDL_Surface *realrainbow_colors[2]; -Uint8 realrainbow_blendr, realrainbow_blendg, realrainbow_blendb, - realrainbow_blenda; +Uint8 realrainbow_blendr, realrainbow_blendg, realrainbow_blendb, realrainbow_blenda; void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x1, int y1, int x2, int y2, - int fulldraw, SDL_Rect * update_rect); -static void realrainbow_linecb(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); + SDL_Surface * last, int x1, int y1, int x2, int y2, int fulldraw, SDL_Rect * update_rect); +static void realrainbow_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); Uint32 realrainbow_api_version(void); int realrainbow_init(magic_api * api, Uint32 disabled_features); int realrainbow_get_tool_count(magic_api * api); @@ -47,21 +44,17 @@ void realrainbow_shutdown(magic_api * api); void realrainbow_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); void realrainbow_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 realrainbow_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); void realrainbow_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); -void realrainbow_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void realrainbow_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); +void realrainbow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void realrainbow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); Uint8 realrainbow_accepted_sizes(magic_api * api, int which, int mode); Uint8 realrainbow_default_size(magic_api * api, int which, int mode); -void realrainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void realrainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 realrainbow_api_version(void) @@ -73,21 +66,17 @@ int realrainbow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-colors.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-colors.png", api->data_directory); realrainbow_colors[0] = IMG_Load(fname); if (realrainbow_colors[0] == NULL) return (0); - snprintf(fname, sizeof(fname), - "%simages/magic/realrainbow-roygbiv-colors.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv-colors.png", api->data_directory); realrainbow_colors[1] = IMG_Load(fname); if (realrainbow_colors[1] == NULL) return (0); - snprintf(fname, sizeof(fname), "%ssounds/magic/realrainbow.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/realrainbow.ogg", api->data_directory); realrainbow_snd = Mix_LoadWAV(fname); return (1); @@ -103,11 +92,9 @@ SDL_Surface *realrainbow_get_icon(magic_api * api, int which) char fname[1024]; if (which == 0) - snprintf(fname, sizeof(fname), "%simages/magic/realrainbow.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/realrainbow.png", api->data_directory); else - snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv.png", api->data_directory); return (IMG_Load(fname)); } @@ -120,29 +107,25 @@ char *realrainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) return (strdup(gettext_noop("ROYGBIV Rainbow"))); } -int realrainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int realrainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } char *realrainbow_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return (strdup (gettext_noop ("Click where you want your rainbow to start, drag to where you want it to end, and then let go to draw a rainbow."))); } -int realrainbow_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int realrainbow_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT_WITH_PREVIEW); } -int realrainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int realrainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (0); } @@ -157,16 +140,17 @@ void realrainbow_shutdown(magic_api * api ATTRIBUTE_UNUSED) Mix_FreeChunk(realrainbow_snd); } -void realrainbow_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) +void realrainbow_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) { } void realrainbow_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { realrainbow_x1 = x; realrainbow_y1 = y; @@ -179,8 +163,7 @@ void realrainbow_click(magic_api * api ATTRIBUTE_UNUSED, void realrainbow_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, - int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int rx1, ry1, rx2, ry2; SDL_Rect rect; @@ -217,8 +200,7 @@ void realrainbow_drag(magic_api * api, int which, } void realrainbow_release(magic_api * api, int which, - 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) { int rx1, ry1, rx2, ry2; SDL_Rect rect; @@ -257,23 +239,18 @@ void realrainbow_release(magic_api * api, int which, } void realrainbow_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 realrainbow_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) { } void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x1, int y1, int x2, int y2, - int fulldraw, SDL_Rect * update_rect) + SDL_Surface * last, int x1, int y1, int x2, int y2, int fulldraw, SDL_Rect * update_rect) { int lowx, lowy, hix, hiy, xm, ym, xc, yc, r, a1, atan2_a, atan2_b; int a, oa, ox, oy, nx, ny, step, thick, rr, done; @@ -320,7 +297,7 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas, if (hix == lowx) return; - slope = (float) (hiy - lowy) / (float) (hix - lowx); + slope = (float)(hiy - lowy) / (float)(hix - lowx); yc = lowy; xc = slope * (ym - yc) + xm; @@ -364,20 +341,16 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas, nx = (rr * cos(a * M_PI / 180.0)) + xc; ny = (rr * sin(a * M_PI / 180.0)) + yc; - colorindex = - realrainbow_colors[which]->h - 1 - - (((rr - r + (thick / 2)) * realrainbow_colors[which]->h) / thick); + colorindex = realrainbow_colors[which]->h - 1 - (((rr - r + (thick / 2)) * realrainbow_colors[which]->h) / thick); SDL_GetRGBA(api->getpixel(realrainbow_colors[which], 0, colorindex), realrainbow_colors[which]->format, &realrainbow_blendr, - &realrainbow_blendg, &realrainbow_blendb, - &realrainbow_blenda); + &realrainbow_blendg, &realrainbow_blendb, &realrainbow_blenda); if (!fulldraw) realrainbow_blenda = 255; - api->line((void *) api, 0, canvas, last, ox, oy, nx, ny, 1, - realrainbow_linecb); + api->line((void *)api, 0, canvas, last, ox, oy, nx, ny, 1, realrainbow_linecb); } oa = a; @@ -396,8 +369,7 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas, } static void realrainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, - int x, int y) + SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; Uint8 origr, origg, origb; @@ -405,21 +377,16 @@ static void realrainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED, SDL_GetRGB(api->getpixel(last, x, y), last->format, &origr, &origg, &origb); - newr = - ((realrainbow_blendr * realrainbow_blenda) / 255) + - ((origr * (255 - realrainbow_blenda)) / 255); - newg = - ((realrainbow_blendg * realrainbow_blenda) / 255) + - ((origg * (255 - realrainbow_blenda)) / 255); - newb = - ((realrainbow_blendb * realrainbow_blenda) / 255) + - ((origb * (255 - realrainbow_blenda)) / 255); + newr = ((realrainbow_blendr * realrainbow_blenda) / 255) + ((origr * (255 - realrainbow_blenda)) / 255); + newg = ((realrainbow_blendg * realrainbow_blenda) / 255) + ((origg * (255 - realrainbow_blenda)) / 255); + newb = ((realrainbow_blendb * realrainbow_blenda) / 255) + ((origb * (255 - realrainbow_blenda)) / 255); api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, newr, newg, newb)); } -Uint8 realrainbow_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +Uint8 realrainbow_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, + int mode ATTRIBUTE_UNUSED) { return 0; } @@ -429,6 +396,8 @@ Uint8 realrainbow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI return 0; } -void realrainbow_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 realrainbow_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) { } diff --git a/magic/src/reflection.c b/magic/src/reflection.c index 313b74914..640e6074e 100644 --- a/magic/src/reflection.c +++ b/magic/src/reflection.c @@ -59,28 +59,24 @@ char *reflection_get_name(magic_api * api, int which); int reflection_get_group(magic_api * api, int which); char *reflection_get_description(magic_api * api, int which, int mode); void reflection_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); void do_reflection(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect, int show_origin); void reflection_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 reflection_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void reflection_shutdown(magic_api * api); void reflection_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int reflection_requires_colors(magic_api * api, int which); -void reflection_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void reflection_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void reflection_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void reflection_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int reflection_modes(magic_api * api, int which); Uint8 reflection_accepted_sizes(magic_api * api, int which, int mode); Uint8 reflection_default_size(magic_api * api, int which, int mode); -void reflection_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void reflection_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -88,8 +84,7 @@ int reflection_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg", api->data_directory); reflection_snd = Mix_LoadWAV(fname); return (1); @@ -114,38 +109,31 @@ SDL_Surface *reflection_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) return (IMG_Load(fname)); } -char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Reflection"))); } -int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } char *reflection_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag the mouse around to add a reflection to your picture."))); + return (strdup(gettext_noop("Click and drag the mouse around to add a reflection to your picture."))); } void reflection_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, - int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { do_reflection(api, canvas, last, x, y, update_rect, 1); } void do_reflection(magic_api * api, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, SDL_Rect * update_rect, - int show_origin) + SDL_Surface * last, int x, int y, SDL_Rect * update_rect, int show_origin) { float scale; int xx, yy; @@ -200,7 +188,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, /* Starting from `reflection_y1` and moving down, we'll copy from `reflection_y1` and moving up */ - scale = (float) reflection_y1 / (float) y; + scale = (float)reflection_y1 / (float)y; for (yy = reflection_y1; yy < canvas->h; yy++) { @@ -232,7 +220,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, /* Starting from `reflection_y1` and moving up, we'll copy from `reflection_y1` and moving down */ - scale = ((float) reflection_y1 / (float) y); + scale = ((float)reflection_y1 / (float)y); for (yy = reflection_y1; yy >= 0; yy--) { @@ -264,7 +252,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, /* Starting from `reflection_x1` and moving right, we'll copy from `reflection_x1` and moving left */ - scale = (float) reflection_x1 / (float) x; + scale = (float)reflection_x1 / (float)x; for (xx = reflection_x1; xx < canvas->w; xx++) { @@ -296,7 +284,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, /* Starting from `reflection_x1` and left up, we'll copy from `reflection_x1` and right down */ - scale = (float) reflection_x1 / (float) x; + scale = (float)reflection_x1 / (float)x; for (xx = reflection_x1; xx >= 0; xx--) { @@ -336,24 +324,20 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, } else { - for (yy = reflection_y1 - REFLECTION_XOR_SIZE; - yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++) + for (yy = reflection_y1 - REFLECTION_XOR_SIZE; yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++) { if (show_origin) api->xorpixel(canvas, reflection_x1, yy); else - api->putpixel(canvas, reflection_x1, yy, - api->getpixel(last, reflection_x1, yy)); + api->putpixel(canvas, reflection_x1, yy, api->getpixel(last, reflection_x1, yy)); } - for (xx = reflection_x1 - REFLECTION_XOR_SIZE; - xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++) + for (xx = reflection_x1 - REFLECTION_XOR_SIZE; xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++) { if (show_origin) api->xorpixel(canvas, xx, reflection_y1); else - api->putpixel(canvas, xx, reflection_y1, - api->getpixel(last, xx, reflection_y1)); + api->putpixel(canvas, xx, reflection_y1, api->getpixel(last, xx, reflection_y1)); } update_rect->x -= REFLECTION_XOR_SIZE; @@ -362,13 +346,11 @@ void do_reflection(magic_api * api, SDL_Surface * canvas, update_rect->h += (REFLECTION_XOR_SIZE * 2); } - api->playsound(reflection_snd, (x * 255) / canvas->w, - (y * 255) / canvas->h); + api->playsound(reflection_snd, (x * 255) / canvas->w, (y * 255) / canvas->h); } void reflection_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) { if (x <= 0) x = 1; @@ -388,8 +370,7 @@ void reflection_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, } void reflection_release(magic_api * api, int which 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) { do_reflection(api, canvas, last, x, y, update_rect, 0); } @@ -400,34 +381,31 @@ void reflection_shutdown(magic_api * api ATTRIBUTE_UNUSED) Mix_FreeChunk(reflection_snd); } -void reflection_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) +void reflection_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) { } -int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void reflection_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { reflection_x1 = canvas->w / 2; reflection_y1 = canvas->h / 2; } void reflection_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 reflection_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int reflection_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT; } @@ -443,6 +421,8 @@ Uint8 reflection_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB return 0; } -void reflection_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 reflection_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) { } diff --git a/magic/src/ripples.c b/magic/src/ripples.c index d936e5694..f09835102 100644 --- a/magic/src/ripples.c +++ b/magic/src/ripples.c @@ -49,27 +49,23 @@ char *ripples_get_name(magic_api * api, int which); int ripples_get_group(magic_api * api, int which); char *ripples_get_description(magic_api * api, int which, int mode); void ripples_drag(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y, - SDL_Rect * update_rect); -static void ripples_linecb(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); + SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect); +static void ripples_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void ripples_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void ripples_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void ripples_shutdown(magic_api * api); void ripples_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int ripples_requires_colors(magic_api * api, int which); -void ripples_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void ripples_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void ripples_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void ripples_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int ripples_modes(magic_api * api, int which); Uint8 ripples_accepted_sizes(magic_api * api, int which, int mode); Uint8 ripples_default_size(magic_api * api, int which, int mode); -void ripples_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void ripples_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 ripples_api_version(void) @@ -85,8 +81,7 @@ int ripples_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/ripples.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/ripples.ogg", api->data_directory); ripples_snd = Mix_LoadWAV(fname); return (1); @@ -103,33 +98,27 @@ SDL_Surface *ripples_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/ripples.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/ripples.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *ripples_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *ripples_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Ripples"))); } // Return our groups: -int ripples_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int ripples_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *ripples_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *ripples_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop("Click to make ripples appear over your picture."))); + return (strdup(gettext_noop("Click to make ripples appear over your picture."))); } // Affect the canvas on drag: @@ -138,14 +127,12 @@ void ripples_drag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy 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) { } static void ripples_linecb(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int x, - int y) + SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; Uint8 r, g, b; @@ -163,8 +150,7 @@ static void ripples_linecb(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on click: void ripples_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) { float fli; int ox, oy, nx, ny, d; @@ -183,18 +169,17 @@ void ripples_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, ripples_brite = (ripples_z * 20 * deg_sin(d + 45)) / ((fli / 4) + 1); - api->line((void *) api, which, canvas, last, ox, oy, nx, ny, 1, - ripples_linecb); + api->line((void *)api, which, canvas, last, ox, oy, nx, ny, 1, ripples_linecb); ox = nx; oy = ny; } } - update_rect->x = x - (int) ripples_radius; - update_rect->y = y - (int) ripples_radius; - update_rect->w = ((int) ripples_radius) * 2; - update_rect->h = ((int) ripples_radius) * 2; + update_rect->x = x - (int)ripples_radius; + update_rect->y = y - (int)ripples_radius; + update_rect->w = ((int)ripples_radius) * 2; + update_rect->h = ((int)ripples_radius) * 2; api->playsound(ripples_snd, (x * 255) / api->canvas_w, 255); } @@ -204,8 +189,7 @@ void ripples_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -217,38 +201,37 @@ void ripples_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void ripples_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) +void ripples_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) { } // Use colors: -int ripples_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int ripples_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void ripples_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 ripples_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 ripples_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int ripples_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_ONECLICK); } -Uint8 ripples_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { +Uint8 ripples_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) +{ return 10; } @@ -257,7 +240,9 @@ Uint8 ripples_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 5; } -void ripples_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 ripples_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) { - ripples_radius = ((float) size) * 20.0; + ripples_radius = ((float)size) * 20.0; } diff --git a/magic/src/rosette.c b/magic/src/rosette.c index 3e5fe81fa..cca8831ee 100644 --- a/magic/src/rosette.c +++ b/magic/src/rosette.c @@ -36,7 +36,7 @@ #include "SDL_mixer.h" #include //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; } diff --git a/magic/src/sharpen.c b/magic/src/sharpen.c index 6bd31518c..0bd21ce31 100644 --- a/magic/src/sharpen.c +++ b/magic/src/sharpen.c @@ -78,15 +78,12 @@ const char *sharpen_names[sharpen_NUM_TOOLS] = { }; const char *sharpen_descs[sharpen_NUM_TOOLS][2] = { - {gettext_noop - ("Click and drag the mouse to trace edges in parts of your picture."), + {gettext_noop("Click and drag the mouse to trace edges in parts of your picture."), gettext_noop("Click to trace edges in your entire picture."),}, {gettext_noop("Click and drag the mouse to sharpen parts of your picture."), gettext_noop("Click to sharpen the entire picture."),}, - {gettext_noop - ("Click and drag the mouse to create a black and white silhouette."), - gettext_noop - ("Click to create a black and white silhouette of your entire picture.")}, + {gettext_noop("Click and drag the mouse to create a black and white silhouette."), + gettext_noop("Click to create a black and white silhouette of your entire picture.")}, }; Uint32 sharpen_api_version(void); @@ -97,34 +94,28 @@ char *sharpen_get_name(magic_api * api, int which); int sharpen_get_group(magic_api * api, int which); char *sharpen_get_description(magic_api * api, int which, int mode); static int sharpen_grey(Uint8 r1, Uint8 g1, Uint8 b1); -static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); -static void do_sharpen_full(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int which); -static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); +static void do_sharpen_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which); +static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void sharpen_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); void sharpen_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void sharpen_release(magic_api * api, int which, - 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 sharpen_shutdown(magic_api * api); void sharpen_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int sharpen_requires_colors(magic_api * api, int which); -void sharpen_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void sharpen_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void sharpen_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void sharpen_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int sharpen_modes(magic_api * api, int which); Uint8 sharpen_accepted_sizes(magic_api * api, int which, int mode); Uint8 sharpen_default_size(magic_api * api, int which, int mode); -void sharpen_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void sharpen_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -143,8 +134,7 @@ int sharpen_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < sharpen_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - sharpen_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, sharpen_snd_filenames[i]); sharpen_snd_effect[i] = Mix_LoadWAV(fname); } @@ -162,8 +152,7 @@ SDL_Surface *sharpen_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - sharpen_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, sharpen_icon_filenames[which]); return (IMG_Load(fname)); } @@ -174,15 +163,13 @@ char *sharpen_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (all the same): -int sharpen_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int sharpen_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_DISTORTS; } // Return our descriptions, localized: -char *sharpen_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode) +char *sharpen_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return (strdup(gettext_noop(sharpen_descs[which][mode - 1]))); } @@ -194,8 +181,7 @@ static int sharpen_grey(Uint8 r1, Uint8 g1, Uint8 b1) } // Do the effect: -static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; @@ -222,8 +208,7 @@ static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, for (j = -1; j < 2; j++) { //No need to check if inside canvas, getpixel does it for us. - SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, - &b1); + SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, &b1); grey = sharpen_grey(r1, g1, b1); sobel_1 += grey * sobel_weights_1[i + 1][j + 1]; sobel_2 += grey * sobel_weights_2[i + 1][j + 1]; @@ -253,14 +238,12 @@ static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, clamp(0.0, r1 + SHARPEN * temp, 255.0), - clamp(0.0, g1 + SHARPEN * temp, 255.0), - clamp(0.0, b1 + SHARPEN * temp, 255.0))); + clamp(0.0, g1 + SHARPEN * temp, 255.0), clamp(0.0, b1 + SHARPEN * temp, 255.0))); } } // Do the effect for the full image -static void do_sharpen_full(void *ptr, SDL_Surface * canvas, - SDL_Surface * last, int which) +static void do_sharpen_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which) { magic_api *api = (magic_api *) ptr; @@ -281,8 +264,7 @@ static void do_sharpen_full(void *ptr, SDL_Surface * canvas, } //do the effect for the brush -static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { int xx, yy; magic_api *api = (magic_api *) ptr; @@ -291,8 +273,7 @@ static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, { for (xx = x - sharpen_RADIUS; xx < x + sharpen_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, sharpen_RADIUS) - && !api->touched(xx, yy)) + if (api->in_circle(xx - x, yy - y, sharpen_RADIUS) && !api->touched(xx, yy)) { do_sharpen_pixel(api, which, canvas, last, xx, yy); } @@ -302,12 +283,10 @@ static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, // Affect the canvas on drag: void sharpen_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_sharpen_brush); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_sharpen_brush); api->playsound(sharpen_snd_effect[which], (x * 255) / canvas->w, 255); @@ -334,8 +313,7 @@ void sharpen_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void sharpen_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) sharpen_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -355,8 +333,7 @@ void sharpen_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -376,32 +353,30 @@ void sharpen_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void sharpen_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) +void sharpen_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) { } // Use colors: -int sharpen_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int sharpen_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void sharpen_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 sharpen_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 sharpen_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int sharpen_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_FULLSCREEN | MODE_PAINT); } @@ -421,7 +396,9 @@ Uint8 sharpen_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 4; } -void sharpen_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 sharpen_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) { sharpen_RADIUS = size * 4; } diff --git a/magic/src/shift.c b/magic/src/shift.c index 4a53130dc..015dce95d 100644 --- a/magic/src/shift.c +++ b/magic/src/shift.c @@ -43,8 +43,7 @@ static Mix_Chunk *shift_snd; /* Local function prototypes: */ static void shift_doit(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y, - SDL_Rect * update_rect, int crosshairs); + SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs); Uint32 shift_api_version(void); int shift_init(magic_api * api, Uint32 disabled_features); int shift_get_tool_count(magic_api * api); @@ -53,8 +52,7 @@ char *shift_get_name(magic_api * api, int which); int shift_get_group(magic_api * api, int which); char *shift_get_description(magic_api * api, int which, int mode); void shift_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); void shift_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void shift_release(magic_api * api, int which, SDL_Surface * canvas, @@ -64,15 +62,14 @@ void shift_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int shift_requires_colors(magic_api * api, int which); -void shift_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void shift_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void shift_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void shift_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int shift_modes(magic_api * api, int which); Uint8 shift_accepted_sizes(magic_api * api, int which, int mode); Uint8 shift_default_size(magic_api * api, int which, int mode); -void shift_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void shift_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -87,8 +84,7 @@ int shift_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/shift.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/shift.ogg", api->data_directory); shift_snd = Mix_LoadWAV(fname); return (1); @@ -101,46 +97,37 @@ int shift_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) } // Load our icons: -SDL_Surface *shift_get_icon(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +SDL_Surface *shift_get_icon(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/shift.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/shift.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *shift_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *shift_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Shift"))); } // Return our group -int shift_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int shift_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } // Return our descriptions, localized: -char *shift_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *shift_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag to shift your picture around on the canvas."))); + return (strdup(gettext_noop("Click and drag to shift your picture around on the canvas."))); } // Affect the canvas on drag: void shift_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) { if (ox == x && oy == y) return; /* No-op */ @@ -151,8 +138,7 @@ void shift_drag(magic_api * api, int which, SDL_Surface * canvas, static void shift_doit(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int ox ATTRIBUTE_UNUSED, - int oy ATTRIBUTE_UNUSED, int x, int y, - SDL_Rect * update_rect, int crosshairs) + int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect, int crosshairs) { SDL_Rect dest; int dx, dy; @@ -313,8 +299,7 @@ static void shift_doit(magic_api * api ATTRIBUTE_UNUSED, // Affect the canvas on click: void shift_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) { shift_x = x; shift_y = y; @@ -324,8 +309,7 @@ void shift_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on release: void shift_release(magic_api * api, int which, - 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) { shift_doit(api, which, canvas, last, x, y, x, y, update_rect, 0); api->stopsound(); @@ -340,27 +324,26 @@ void shift_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void shift_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) +void shift_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) { } // Use colors: -int shift_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int shift_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void shift_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 shift_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) { } @@ -380,6 +363,8 @@ Uint8 shift_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 0; } -void shift_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 shift_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) { } diff --git a/magic/src/smudge.c b/magic/src/smudge.c index 55bd0fa2b..4344a1a97 100644 --- a/magic/src/smudge.c +++ b/magic/src/smudge.c @@ -48,11 +48,9 @@ SDL_Surface *smudge_get_icon(magic_api * api, int which); char *smudge_get_name(magic_api * api, int which); int smudge_get_group(magic_api * api, int which); char *smudge_get_description(magic_api * api, int which, int mode); -static void do_smudge(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_smudge(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void smudge_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); void smudge_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void smudge_release(magic_api * api, int which, SDL_Surface * canvas, @@ -61,23 +59,21 @@ void smudge_shutdown(magic_api * api); void smudge_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int smudge_requires_colors(magic_api * api, int which); -void smudge_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void smudge_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void smudge_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void smudge_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int smudge_modes(magic_api * api, int which); int smudge_get_tool_count(magic_api * api); Uint8 smudge_accepted_sizes(magic_api * api, int which, int mode); Uint8 smudge_default_size(magic_api * api, int which, int mode); -void smudge_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void smudge_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); int smudge_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/smudge.wav", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/smudge.wav", api->data_directory); smudge_snd = Mix_LoadWAV(fname); return (1); @@ -100,11 +96,9 @@ SDL_Surface *smudge_get_icon(magic_api * api, int which) char fname[1024]; if (which == 0) - snprintf(fname, sizeof(fname), "%simages/magic/smudge.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/smudge.png", api->data_directory); else /* if (which == 1) */ - snprintf(fname, sizeof(fname), "%simages/magic/wetpaint.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/wetpaint.png", api->data_directory); return (IMG_Load(fname)); } @@ -128,23 +122,17 @@ int smudge_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *smudge_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *smudge_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { if (which == 0) - return (strdup - (gettext_noop - ("Click and drag the mouse around to smudge the picture."))); + return (strdup(gettext_noop("Click and drag the mouse around to smudge the picture."))); else /* if (which == 1) */ - return (strdup - (gettext_noop - ("Click and drag the mouse around to draw with wet, smudgy paint."))); + return (strdup(gettext_noop("Click and drag the mouse around to draw with wet, smudgy paint."))); } // Do the effect: -static void do_smudge(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y) +static void do_smudge(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { magic_api *api = (magic_api *) ptr; static double state[256][256][3]; @@ -160,8 +148,7 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas, for (xx = -(smudge_radius / 2); xx < (smudge_radius / 2); xx++) if (api->in_circle(xx, yy, (smudge_radius / 2))) { - SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r, - &g, &b); + SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r, &g, &b); strength = (abs(xx * yy) / (smudge_radius / 2)) + 1; api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, (smudge_r + @@ -169,10 +156,7 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas, (strength + 1), (smudge_g + g * strength) / - (strength + 1), - (smudge_b + - b * strength) / - (strength + 1))); + (strength + 1), (smudge_b + b * strength) / (strength + 1))); } } @@ -182,37 +166,31 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas, int ix = i % (smudge_radius * 2); int radius_check; - radius_check = (smudge_radius * 75) / 10; /* For 16 radius, we'll use 120 */ + radius_check = (smudge_radius * 75) / 10; /* For 16 radius, we'll use 120 */ // is it not on the circle of radius sqrt(radius_check) at location (smudge_radius,smudge_radius)? if ((ix - smudge_radius) * (ix - smudge_radius) + (iy - smudge_radius) * (iy - smudge_radius) > radius_check) continue; // it is on the circle, so grab it - SDL_GetRGB(api->getpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius), last->format, - &r, &g, &b); - state[ix][iy][0] = - rate * state[ix][iy][0] + (1.0 - rate) * api->sRGB_to_linear(r); - state[ix][iy][1] = - rate * state[ix][iy][1] + (1.0 - rate) * api->sRGB_to_linear(g); - state[ix][iy][2] = - rate * state[ix][iy][2] + (1.0 - rate) * api->sRGB_to_linear(b); + SDL_GetRGB(api->getpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius), last->format, &r, &g, &b); + state[ix][iy][0] = rate * state[ix][iy][0] + (1.0 - rate) * api->sRGB_to_linear(r); + state[ix][iy][1] = rate * state[ix][iy][1] + (1.0 - rate) * api->sRGB_to_linear(g); + state[ix][iy][2] = rate * state[ix][iy][2] + (1.0 - rate) * api->sRGB_to_linear(b); // opacity 100% --> new data not blended w/ existing data api->putpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius, SDL_MapRGB(canvas->format, api->linear_to_sRGB(state[ix][iy][0]), - api->linear_to_sRGB(state[ix][iy][1]), - api->linear_to_sRGB(state[ix][iy][2]))); + api->linear_to_sRGB(state[ix][iy][1]), api->linear_to_sRGB(state[ix][iy][2]))); } } // Affect the canvas on drag: void smudge_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_smudge); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_smudge); api->playsound(smudge_snd, (x * 255) / canvas->w, 255); @@ -239,8 +217,7 @@ void smudge_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void smudge_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) { smudge_drag(api, which, canvas, last, x, y, x, y, update_rect); } @@ -250,8 +227,7 @@ void smudge_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -263,8 +239,9 @@ void smudge_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void smudge_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 smudge_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) { smudge_r = r; smudge_g = g; @@ -272,8 +249,7 @@ void smudge_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS } // Use colors: -int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { if (which == 0) return 0; @@ -282,14 +258,12 @@ int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED, } void smudge_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 smudge_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) { } @@ -310,7 +284,9 @@ Uint8 smudge_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 4; } -void smudge_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 smudge_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) { smudge_radius = size * 4; } diff --git a/magic/src/snow.c b/magic/src/snow.c index 5454815f5..ae735c37e 100644 --- a/magic/src/snow.c +++ b/magic/src/snow.c @@ -89,29 +89,25 @@ SDL_Surface *snow_get_icon(magic_api * api, int which); char *snow_get_name(magic_api * api, int which); int snow_get_group(magic_api * api, int which); char *snow_get_description(magic_api * api, int which); -static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which, int snowAmount); +static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which, int snowAmount); void snow_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); void snow_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void snow_release(magic_api * api, int which, - 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 snow_shutdown(magic_api * api); void snow_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int snow_requires_colors(magic_api * api, int which); -void snow_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void snow_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void snow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void snow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int snow_modes(magic_api * api, int which); Uint8 snow_accepted_sizes(magic_api * api, int which, int mode); Uint8 snow_default_size(magic_api * api, int which, int mode); -void snow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void snow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 snow_api_version(void) @@ -128,16 +124,14 @@ int snow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) srand(time(0)); - snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake4.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake4.png", api->data_directory); snow_flake1 = IMG_Load(fname); if (snow_flake1 == NULL) { return (0); } - snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake5.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake5.png", api->data_directory); snow_flake2 = IMG_Load(fname); if (snow_flake2 == NULL) { @@ -146,8 +140,7 @@ int snow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) for (i = 0; i < snow_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - snow_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, snow_snd_filenames[i]); snow_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -163,8 +156,7 @@ SDL_Surface *snow_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - snow_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, snow_icon_filenames[which]); return (IMG_Load(fname)); } @@ -174,8 +166,7 @@ char *snow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) return (strdup(gettext_noop(snow_names[which]))); } -int snow_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int snow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_DECORATIONS; /* Because we affect the whole image, and not just around the mouse */ } @@ -187,8 +178,7 @@ char *snow_get_description(magic_api * api ATTRIBUTE_UNUSED, int which) } // Do the effect: -static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, - int which, int snowAmount) +static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which, int snowAmount) { magic_api *api = (magic_api *) ptr; @@ -208,10 +198,8 @@ static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, { if (api->in_circle(x, y, snow_RADIUS)) { - SDL_GetRGB(api->getpixel(last, centre_x + x, centre_y + y), - last->format, &r, &g, &b); - api->putpixel(canvas, centre_x + x, centre_y + y, - SDL_MapRGB(canvas->format, 255, 255, 255)); + SDL_GetRGB(api->getpixel(last, centre_x + x, centre_y + y), last->format, &r, &g, &b); + api->putpixel(canvas, centre_x + x, centre_y + y, SDL_MapRGB(canvas->format, 255, 255, 255)); } } } @@ -237,8 +225,7 @@ void snow_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x ATTRIBUTE_UNUSED, - int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect ATTRIBUTE_UNUSED) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { // No-op } @@ -246,8 +233,7 @@ void snow_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, // Affect the canvas on click: void snow_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect) { update_rect->x = 0; update_rect->y = 0; @@ -263,8 +249,7 @@ void snow_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) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -293,26 +278,24 @@ void snow_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void snow_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 * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, + Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } // Use colors: -int snow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int snow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void snow_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 snow_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) { } @@ -333,6 +316,8 @@ Uint8 snow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 0; } -void snow_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 snow_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) { } diff --git a/magic/src/stretch.c b/magic/src/stretch.c index dcd6d6175..c6c8db944 100644 --- a/magic/src/stretch.c +++ b/magic/src/stretch.c @@ -60,25 +60,21 @@ int stretch_get_group(magic_api * api, int which); char *stretch_get_description(magic_api * api, int which, int mode); int stretch_requires_colors(magic_api * api, int which); void stretch_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 stretch_shutdown(magic_api * api); void stretch_paint_stretch(void *ptr_to_api, int which_tool, - SDL_Surface * canvas, SDL_Surface * snapshot, - int x, int y); + SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void stretch_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 stretch_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); -void stretch_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void stretch_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void stretch_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void stretch_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int stretch_modes(magic_api * api, int which); Uint8 stretch_accepted_sizes(magic_api * api, int which, int mode); Uint8 stretch_default_size(magic_api * api, int which, int mode); -void stretch_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void stretch_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // Housekeeping functions Uint32 stretch_api_version(void) @@ -86,8 +82,10 @@ Uint32 stretch_api_version(void) return (TP_MAGIC_API_VERSION); } -void stretch_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) +void stretch_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) { } @@ -95,8 +93,7 @@ int stretch_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/stretch.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/stretch.ogg", api->data_directory); stretch_snd = Mix_LoadWAV(fname); return (1); @@ -111,35 +108,27 @@ SDL_Surface *stretch_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/stretch.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/stretch.png", api->data_directory); return (IMG_Load(fname)); } -char *stretch_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *stretch_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Stretch")); } -int stretch_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int stretch_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } -char *stretch_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *stretch_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return - strdup(gettext_noop - ("Click and drag to stretch part of your picture vertically or horizontally.")); + return strdup(gettext_noop("Click and drag to stretch part of your picture vertically or horizontally.")); } -int stretch_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int stretch_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -148,8 +137,7 @@ void stretch_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) { } @@ -162,8 +150,7 @@ void stretch_shutdown(magic_api * api ATTRIBUTE_UNUSED) void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, - int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { SDL_Rect src, dest; float xx, yy; @@ -177,9 +164,8 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED, { if (y != stretch_start_y) { - divisor1 = (float) y / (float) stretch_start_y; - divisor2 = - (float) (canvas->h - y) / (float) (canvas->h - stretch_start_y); + divisor1 = (float)y / (float)stretch_start_y; + divisor2 = (float)(canvas->h - y) / (float)(canvas->h - stretch_start_y); for (yy = 0; yy < y; yy++) { @@ -220,9 +206,8 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED, { if (x != stretch_start_x) { - divisor1 = (float) x / (float) stretch_start_x; - divisor2 = - (float) (canvas->w - x) / (float) (canvas->w - stretch_start_x); + divisor1 = (float)x / (float)stretch_start_x; + divisor2 = (float)(canvas->w - x) / (float)(canvas->w - stretch_start_x); for (xx = 0; xx < x; xx++) { @@ -267,8 +252,7 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED, } void stretch_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) { if (y < canvas->h / 2) { @@ -296,21 +280,18 @@ void stretch_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, } void stretch_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 stretch_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 stretch_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int stretch_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -326,6 +307,8 @@ Uint8 stretch_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 0; } -void stretch_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 stretch_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) { } diff --git a/magic/src/string.c b/magic/src/string.c index 714c2cbc0..ba0bd3aa3 100644 --- a/magic/src/string.c +++ b/magic/src/string.c @@ -10,8 +10,7 @@ unsigned int img_w, img_h; static Uint8 string_r, string_g, string_b; static int string_ox, string_oy; -static int string_vertex_x, string_vertex_y, string_vertex_done, - string_vertex_distance; +static int string_vertex_x, string_vertex_y, string_vertex_done, string_vertex_distance; static SDL_Surface *canvas_backup; enum string_tools { @@ -25,24 +24,18 @@ Mix_Chunk *string_snd[STRING_NUMTOOLS]; // Custom function declarations -void string_callback(void *ptr, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); -void string_callback_xor(void *ptr, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +void string_callback(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); +void string_callback_xor(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void string_draw_triangle(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 string_draw_angle(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 string_draw_triangle_preview(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 string_draw_angle_preview(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, - int ox, int oy, int x, int y, - SDL_Rect * update_rect); + int ox, int oy, int x, int y, SDL_Rect * update_rect); void scale_xcoord(int *xcoord); void scale_ycoord(int *ycoord); void scale_coords(int *ox, int *oy, int *x, int *y); @@ -56,8 +49,7 @@ void compute_middle(int start_point, int end_point, int vertex, int *middle); // Prototypes for required functions void string_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); Uint32 string_api_version(void); @@ -71,20 +63,18 @@ int string_get_group(magic_api * api, int which); char *string_get_description(magic_api * api, int which, int mode); int string_requires_colors(magic_api * api, int which); void string_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 string_init(magic_api * api, Uint32 disabled_features); void string_shutdown(magic_api * api); -void string_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * snapshot); -void string_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * snapshot); +void string_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot); +void string_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot); void string_click(magic_api * api, int which, int mode, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); Uint8 string_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); Uint8 string_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED); -void string_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 string_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); // Required functions @@ -101,8 +91,9 @@ int string_modes(magic_api * api ATTRIBUTE_UNUSED, int which) return (MODE_PAINT_WITH_PREVIEW); } -void string_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 string_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) { string_r = r; string_g = g; @@ -123,17 +114,13 @@ SDL_Surface *string_get_icon(magic_api * api, int which) switch (which) { case STRING_TOOL_FULL_BY_OFFSET: - snprintf(fname, sizeof(fname), - "%simages/magic/string_art_full_by_offset.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/string_art_full_by_offset.png", api->data_directory); break; case STRING_TOOL_TRIANGLE: - snprintf(fname, sizeof(fname), "%simages/magic/string_art_triangles.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/string_art_triangles.png", api->data_directory); break; case STRING_TOOL_ANGLE: - snprintf(fname, sizeof(fname), "%simages/magic/string_art_angles.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/string_art_angles.png", api->data_directory); break; } @@ -141,8 +128,7 @@ SDL_Surface *string_get_icon(magic_api * api, int which) } -char *string_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *string_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { switch (which) { @@ -157,14 +143,12 @@ char *string_get_name(magic_api * api ATTRIBUTE_UNUSED, } } -int string_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int string_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } -char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { switch (which) { @@ -174,30 +158,25 @@ char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, ("Click and drag to draw string art. Drag top-bottom to draw less or more lines, left or right to make a bigger hole.")); break; case STRING_TOOL_TRIANGLE: - return - strdup(gettext_noop - ("Click and drag to draw arrows made of string art.")); + return strdup(gettext_noop("Click and drag to draw arrows made of string art.")); break; default: return strdup(gettext_noop("Draw string art arrows with free angles.")); } } -int string_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int string_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } void string_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 dx, dy; if (which == STRING_TOOL_TRIANGLE) - string_draw_triangle((void *) api, which, canvas, snapshot, string_ox, - string_oy, x, y, update_rect); + string_draw_triangle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect); if (which == STRING_TOOL_ANGLE) { if (!string_vertex_done) // maybe we face small children, draw square angles aligned to the drag @@ -207,8 +186,7 @@ void string_release(magic_api * api, int which, y = y + dx; x = x - dy; } - string_draw_angle((void *) api, which, canvas, snapshot, string_ox, - string_oy, x, y, update_rect); + string_draw_angle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect); } } @@ -216,16 +194,13 @@ int string_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/string.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/string.ogg", api->data_directory); string_snd[STRING_TOOL_FULL_BY_OFFSET] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/string2.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/string2.ogg", api->data_directory); string_snd[STRING_TOOL_TRIANGLE] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/string3.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/string3.ogg", api->data_directory); string_snd[STRING_TOOL_ANGLE] = Mix_LoadWAV(fname); return (1); @@ -248,20 +223,17 @@ void string_shutdown(magic_api * api ATTRIBUTE_UNUSED) void string_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * snapshot ATTRIBUTE_UNUSED) + SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED) { canvas_backup = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); } void string_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * snapshot ATTRIBUTE_UNUSED) + SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED) { SDL_FreeSurface(canvas_backup); canvas_backup = NULL; @@ -271,19 +243,15 @@ void string_switchout(magic_api * api ATTRIBUTE_UNUSED, void string_callback(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; - api->putpixel(canvas, x, y, - SDL_MapRGBA(canvas->format, string_r, string_g, string_b, - 255)); + api->putpixel(canvas, x, y, SDL_MapRGBA(canvas->format, string_r, string_g, string_b, 255)); } void string_callback_xor(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; @@ -292,8 +260,7 @@ void string_callback_xor(void *ptr, int which ATTRIBUTE_UNUSED, void string_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) { SDL_BlitSurface(canvas, NULL, canvas_backup, NULL); @@ -306,9 +273,7 @@ void string_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, - SDL_Surface * - snapshot ATTRIBUTE_UNUSED, int x, - int y, SDL_Rect * update_rect) + SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { magic_api *api = (magic_api *) ptr; int u; @@ -318,16 +283,16 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED, // int n=y/5; int **a; float step_w, step_h, aux; - int side = (int) (y / 3); + int side = (int)(y / 3); SDL_BlitSurface(snapshot, 0, canvas, 0); if (side < 3) side = 3; - o = (int) (side * 4 * x / canvas->w); - step_w = canvas->w / (float) side; - step_h = canvas->h / (float) side; + o = (int)(side * 4 * x / canvas->w); + step_w = canvas->w / (float)side; + step_h = canvas->h / (float)side; a = malloc(sizeof(int *) * side * 4 * 2); @@ -337,22 +302,22 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED, if (i < side) { a[i][0] = 0; - aux = step_h * (float) i; - a[i][1] = (int) aux; + aux = step_h * (float)i; + a[i][1] = (int)aux; } else if (i < (side * 2)) { - a[i][0] = (int) ((float) (i % side) * step_w); + a[i][0] = (int)((float)(i % side) * step_w); a[i][1] = canvas->h; } - else if (i < (int) (side * 3)) + else if (i < (int)(side * 3)) { a[i][0] = canvas->w; - a[i][1] = (int) (canvas->h - (float) ((i % side) * step_h)); + a[i][1] = (int)(canvas->h - (float)((i % side) * step_h)); } - else if (i < (int) (side * 4)) + else if (i < (int)(side * 4)) { - a[i][0] = (int) (canvas->w - ((float) ((i % side) * step_w))); + a[i][0] = (int)(canvas->w - ((float)((i % side) * step_w))); a[i][1] = 0; } } @@ -361,8 +326,7 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED, for (i = 0; i < side * 4; i++) { u = (i + o) % (side * 4); - api->line((void *) api, which, canvas, snapshot, a[i][0], a[i][1], - a[u][0], a[u][1], 1, string_callback); + api->line((void *)api, which, canvas, snapshot, a[i][0], a[i][1], a[u][0], a[u][1], 1, string_callback); } for (i = 0; i < side * 4; i++) @@ -403,18 +367,13 @@ void scale_coords(int *ox, int *oy, int *x, int *y) void compute_middle(int start_point, int end_point, int vertex, int *middle) { - *middle = - min(start_point, - end_point) + (max(start_point, end_point) - min(start_point, - end_point)) / 2; - *middle = - min(*middle, vertex) + (max(*middle, vertex) - min(*middle, vertex)) / 2; + *middle = min(start_point, end_point) + (max(start_point, end_point) - min(start_point, end_point)) / 2; + *middle = min(*middle, vertex) + (max(*middle, vertex) - min(*middle, vertex)) / 2; } void string_draw_triangle_preview(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) { int middle_x, middle_y; @@ -429,21 +388,15 @@ void string_draw_triangle_preview(magic_api * api, int which, compute_middle(x, string_ox, string_ox, &middle_x); compute_middle(y, string_oy, string_oy, &middle_y); - api->line((void *) api, which, canvas, snapshot, string_ox, string_oy, - string_ox, y, 1, string_callback_xor); - api->line((void *) api, which, canvas, snapshot, string_ox, string_oy, x, - string_oy, 1, string_callback_xor); - api->line((void *) api, which, canvas, snapshot, middle_x, middle_y, x, - string_oy, 1, string_callback_xor); - api->line((void *) api, which, canvas, snapshot, string_ox, y, middle_x, - middle_y, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, string_ox, y, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, x, string_oy, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, middle_x, middle_y, x, string_oy, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, string_ox, y, middle_x, middle_y, 1, string_callback_xor); } void string_draw_angle_preview(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) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int middle_x, middle_y; int dx, dy; @@ -454,7 +407,7 @@ void string_draw_angle_preview(magic_api * api, int which, update_rect->h = canvas->h; SDL_BlitSurface(canvas_backup, update_rect, canvas, update_rect); - api->line((void *) api, which, canvas, snapshot, string_ox, string_oy, + api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, string_vertex_x, string_vertex_y, 1, string_callback_xor); if (!string_vertex_done) { @@ -469,22 +422,17 @@ void string_draw_angle_preview(magic_api * api, int which, compute_middle(string_ox, x, string_vertex_x, &middle_x); compute_middle(string_oy, y, string_vertex_y, &middle_y); - api->line((void *) api, which, canvas, snapshot, string_vertex_x, - string_vertex_y, x, y, 1, string_callback_xor); - api->line((void *) api, which, canvas, snapshot, string_ox, string_oy, - middle_x, middle_y, 1, string_callback_xor); - api->line((void *) api, which, canvas, snapshot, x, y, middle_x, middle_y, - 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, string_vertex_x, string_vertex_y, x, y, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, middle_x, middle_y, 1, string_callback_xor); + api->line((void *)api, which, canvas, snapshot, x, y, middle_x, middle_y, 1, string_callback_xor); } void string_draw_angle(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, - int x, int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { - float first_arm_step_x, first_arm_step_y, second_arm_step_x, - second_arm_step_y; + float first_arm_step_x, first_arm_step_y, second_arm_step_x, second_arm_step_y; int i; int max_wh, steps; int max_separation = 10; @@ -498,29 +446,26 @@ void string_draw_angle(magic_api * api, int which ATTRIBUTE_UNUSED, max_wh = max(max(max(string_ox, string_vertex_x), x) - min(min(string_vertex_x, x), string_ox), - max(max(string_oy, string_vertex_y), y) - min(min(string_vertex_y, y), - string_oy)); + max(max(string_oy, string_vertex_y), y) - min(min(string_vertex_y, y), string_oy)); steps = max_wh / max_separation; - first_arm_step_x = (float) (string_ox - string_vertex_x) / (float) steps; - first_arm_step_y = (float) (string_oy - string_vertex_y) / (float) steps; - second_arm_step_x = (float) (string_vertex_x - x) / (float) steps; - second_arm_step_y = (float) (string_vertex_y - y) / (float) steps; + first_arm_step_x = (float)(string_ox - string_vertex_x) / (float)steps; + first_arm_step_y = (float)(string_oy - string_vertex_y) / (float)steps; + second_arm_step_x = (float)(string_vertex_x - x) / (float)steps; + second_arm_step_y = (float)(string_vertex_y - y) / (float)steps; for (i = 0; i <= steps; i++) { - api->line((void *) api, 0, canvas, snapshot, + api->line((void *)api, 0, canvas, snapshot, string_ox - first_arm_step_x * i, string_oy - first_arm_step_y * i, - string_vertex_x - second_arm_step_x * i, - string_vertex_y - second_arm_step_y * i, 1, string_callback); + string_vertex_x - second_arm_step_x * i, string_vertex_y - second_arm_step_y * i, 1, string_callback); } } void string_draw_triangle(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot, - int ox, int oy, int x, int y, - SDL_Rect * update_rect) + int ox, int oy, int x, int y, SDL_Rect * update_rect) { SDL_BlitSurface(canvas_backup, 0, canvas, 0); scale_coords(&ox, &oy, &x, &y); @@ -531,8 +476,7 @@ void string_draw_triangle(magic_api * api, int which ATTRIBUTE_UNUSED, string_oy = y; y = string_vertex_y; - string_draw_angle((void *) api, which, canvas, snapshot, string_ox, - string_oy, x, y, update_rect); + string_draw_angle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect); } void string_draw_wrapper(magic_api * api, int which, @@ -540,14 +484,11 @@ void string_draw_wrapper(magic_api * api, int which, int oy, int x, int y, SDL_Rect * update_rect) { if (which == STRING_TOOL_FULL_BY_OFFSET) - string_draw_full_by_offset((void *) api, which, canvas, snapshot, x, y, - update_rect); + string_draw_full_by_offset((void *)api, which, canvas, snapshot, x, y, update_rect); else if (which == STRING_TOOL_TRIANGLE) - string_draw_triangle_preview((void *) api, which, canvas, snapshot, ox, - oy, x, y, update_rect); + string_draw_triangle_preview((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect); else if (which == STRING_TOOL_ANGLE) - string_draw_angle_preview((void *) api, which, canvas, snapshot, ox, oy, - x, y, update_rect); + string_draw_angle_preview((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect); } void string_set_vertex(int x, int y) @@ -569,16 +510,13 @@ void string_set_vertex(int x, int y) } void string_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 * canvas, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect) { if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w) - && (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0) - && ((signed) ox > 0) && ((signed) oy > 0)) + && (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0)) { string_set_vertex(x, y); - string_draw_wrapper((void *) api, which, canvas, snapshot, ox, oy, x, y, - update_rect); + string_draw_wrapper((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect); api->playsound(string_snd[which], (x * 255) / canvas->w, 255); } @@ -596,6 +534,8 @@ Uint8 string_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 0; } -void string_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 string_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) { } diff --git a/magic/src/swirls.c b/magic/src/swirls.c index 629e5269a..b4ccd4236 100644 --- a/magic/src/swirls.c +++ b/magic/src/swirls.c @@ -19,41 +19,39 @@ #include "SDL_image.h" #include "SDL_mixer.h" -enum { +enum +{ SWIRL_TOOL_CIRCLES, SWIRL_TOOL_RAYS, SWIRL_TOOL_FUR, NUM_SWIRL_TOOLS }; -char * swirl_names[NUM_SWIRL_TOOLS] = { +char *swirl_names[NUM_SWIRL_TOOLS] = { gettext_noop("Circles"), gettext_noop("Rays"), gettext_noop("Fur") }; -char * swirl_descriptions[NUM_SWIRL_TOOLS][2] = { +char *swirl_descriptions[NUM_SWIRL_TOOLS][2] = { { gettext_noop("Click and drag to transform parts of your picture to circular brushstrokes."), - gettext_noop("Click to turn your entire picture into circular brushstrokes.") - }, + gettext_noop("Click to turn your entire picture into circular brushstrokes.")}, { gettext_noop("Click and drag to transform parts of your picture to brushstroke rays."), - gettext_noop("Click to turn your entire picture into brushstroke rays.") - }, + gettext_noop("Click to turn your entire picture into brushstroke rays.")}, { gettext_noop("Click and drag to add fur to your picture."), - "" - }, + ""}, }; -char * swirl_icon_filenames[NUM_SWIRL_TOOLS] = { +char *swirl_icon_filenames[NUM_SWIRL_TOOLS] = { "swirls_circles.png", "swirls_rays.png", "swirls_fur.png" }; -char * swirl_sfx_filenames[NUM_SWIRL_TOOLS] = { +char *swirl_sfx_filenames[NUM_SWIRL_TOOLS] = { "swirls_circles.ogg", "swirls_rays.ogg", "swirls_fur.ogg" @@ -78,7 +76,7 @@ int SWIRLS_STROKE_LENGTH[NUM_SWIRL_TOOLS] = { }; Mix_Chunk *snd_effects[NUM_SWIRL_TOOLS]; -SDL_Surface * swirls_snapshot = NULL; +SDL_Surface *swirls_snapshot = NULL; int swirls_start_x, swirls_start_y; Uint32 swirl_stroke_color; Uint8 swirl_fur_color_r, swirl_fur_color_g, swirl_fur_color_b; @@ -94,31 +92,24 @@ int swirls_requires_colors(magic_api * api, int which); int swirls_modes(magic_api * api, int which); void swirls_shutdown(magic_api * api); void swirls_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 swirls_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 swirls_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 swirls_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); + SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect); +void swirls_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y); void swirls_line_callback_draw_stroke(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); void swirls_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y, - SDL_Rect * update_rect); -void swirls_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void swirls_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); + SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect); +void swirls_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void swirls_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); double get_angle(int x, int y, int target_x, int target_y); Uint8 swirls_accepted_sizes(magic_api * api, int which, int mode); Uint8 swirls_default_size(magic_api * api, int which, int mode); -void swirls_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void swirls_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 swirls_api_version(void) @@ -131,9 +122,9 @@ int swirls_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) int i; char fname[1024]; - for (i = 0; i < NUM_SWIRL_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", - api->data_directory, swirl_sfx_filenames[i]); + for (i = 0; i < NUM_SWIRL_TOOLS; i++) + { + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, swirl_sfx_filenames[i]); snd_effects[i] = Mix_LoadWAV(fname); } @@ -150,50 +141,53 @@ SDL_Surface *swirls_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", - api->data_directory, swirl_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, swirl_icon_filenames[which]); return (IMG_Load(fname)); } -char *swirls_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which) +char *swirls_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) { return strdup(gettext(swirl_names[which])); } -int swirls_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int swirls_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { return MAGIC_TYPE_PAINTING; - } else { + } + else + { return MAGIC_TYPE_DISTORTS; } } -char *swirls_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which, int mode) +char *swirls_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { return strdup(gettext(swirl_descriptions[which][mode - 1])); } -int swirls_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which) +int swirls_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which) { - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { return 1; - } else { + } + else + { return 0; } } -int swirls_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int swirls_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { return MODE_PAINT; - } else { + } + else + { return (MODE_PAINT | MODE_FULLSCREEN); } } @@ -202,7 +196,8 @@ void swirls_shutdown(magic_api * api ATTRIBUTE_UNUSED) { int i; - for (i = 0; i < NUM_SWIRL_TOOLS; i++) { + for (i = 0; i < NUM_SWIRL_TOOLS; i++) + { if (snd_effects[i] != NULL) Mix_FreeChunk(snd_effects[i]); } @@ -210,8 +205,7 @@ void swirls_shutdown(magic_api * api ATTRIBUTE_UNUSED) void swirls_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) { if (snd_effects[which] != NULL) api->stopsound(); @@ -219,16 +213,23 @@ swirls_click(magic_api * api, int which, int mode, swirls_start_x = x; swirls_start_y = y; - if (mode == MODE_PAINT) { + if (mode == MODE_PAINT) + { swirls_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); - } else { - if (snd_effects[which] != NULL) { + } + else + { + if (snd_effects[which] != NULL) + { api->playsound(snd_effects[which], (x * 255) / canvas->w, 255); } - for (x = 0; x < canvas->w; x++) { - for (y = 0; y < canvas->h; y++) { - if (rand() % 100 == 0) { + for (x = 0; x < canvas->w; x++) + { + for (y = 0; y < canvas->h; y++) + { + if (rand() % 100 == 0) + { swirls_draw_stroke(api, which, canvas, x, y); } } @@ -244,14 +245,15 @@ swirls_click(magic_api * api, int which, int mode, void swirls_drag(magic_api * api ATTRIBUTE_UNUSED, 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) { - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { swirls_start_x = x; swirls_start_y = y; } - api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */, + api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */ , swirls_line_callback_drag); /* FIXME: Would be good to only update the area around the line (ox,oy)->(x,y) (+/- the maxium radius of the effect) */ @@ -263,10 +265,10 @@ swirls_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, void swirls_release(magic_api * api, int which, - SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * snapshot ATTRIBUTE_UNUSED, - int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, - SDL_Rect * update_rect 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) +{ if (snd_effects[which] != NULL && which != SWIRL_TOOL_FUR) api->stopsound(); } @@ -275,8 +277,7 @@ void swirls_release(magic_api * api, int which, void swirls_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) + Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { swirl_fur_color_r = r; swirl_fur_color_g = g; @@ -285,9 +286,7 @@ void swirls_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS void swirls_line_callback_drag(void *ptr, int which, - SDL_Surface * canvas, - SDL_Surface * snapshot ATTRIBUTE_UNUSED, - int x, int y) + SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y) { int i, ang_deg, radius, nx, ny; double ang_rad; @@ -296,19 +295,21 @@ void swirls_line_callback_drag(void *ptr, int which, if (snd_effects[which] != NULL) api->playsound(snd_effects[which], (x * 255) / canvas->w, 255); - for (i = 0; i < SWIRLS_NUM_STROKES_PER_DRAG_LINE[which]; i++) { + for (i = 0; i < SWIRLS_NUM_STROKES_PER_DRAG_LINE[which]; i++) + { ang_deg = (rand() % 360); ang_rad = (ang_deg * M_PI) / 180.0; radius = (rand() % (SWIRLS_DRAG_LINE_STROKE_RADIUS[which] * 2)) - SWIRLS_DRAG_LINE_STROKE_RADIUS[which]; - nx = x + (int) (cos(ang_rad) * radius); - ny = y + (int) (sin(ang_rad) * radius); + nx = x + (int)(cos(ang_rad) * radius); + ny = y + (int)(sin(ang_rad) * radius); swirls_draw_stroke(api, which, canvas, nx, ny); } } -void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y) { +void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y) +{ int x1, y1, x2, y2, len; double a; Uint8 r, g, b; @@ -317,66 +318,85 @@ void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, len = SWIRLS_STROKE_LENGTH[which]; a = get_angle(x, y, swirls_start_x, swirls_start_y); - if (which == SWIRL_TOOL_CIRCLES) { + if (which == SWIRL_TOOL_CIRCLES) + { a = a + (M_PI / 2.0); } x1 = x - cos(a) * len; y1 = y - sin(a) * len; - + x2 = x + cos(a) * len; y2 = y + sin(a) * len; - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { r = swirl_fur_color_r; g = swirl_fur_color_g; b = swirl_fur_color_b; - } else { + } + else + { swirl_stroke_color = api->getpixel(swirls_snapshot, x, y); SDL_GetRGB(swirl_stroke_color, canvas->format, &r, &g, &b); } api->rgbtohsv(r, g, b, &h, &s, &v); h = h + (((rand() % 7) - 3) / 10.0); - if (s > 0.00) { + if (s > 0.00) + { s = s + (((rand() % 3) - 1) / 10.0); } v = v + (((rand() % 3) - 1) / 10.0); - if (h < 0.0) { - h = h - 360.0; - } else if (h >= 360.0) { + if (h < 0.0) + { h = h - 360.0; } - if (s < 0.0) { + else if (h >= 360.0) + { + h = h - 360.0; + } + if (s < 0.0) + { s = 0.0; - } else if (s > 1.0) { + } + else if (s > 1.0) + { s = 1.0; } - if (v < 0.0) { + if (v < 0.0) + { v = 0.0; - } else if (v > 1.0) { + } + else if (v > 1.0) + { v = 1.0; } api->hsvtorgb(h, s, v, &r, &g, &b); swirl_stroke_color = SDL_MapRGB(canvas->format, r, g, b); - api->line((void *) api, which, canvas, NULL /* N/A */, + api->line((void *)api, which, canvas, NULL /* N/A */ , x1, y1, x2, y2, 1, swirls_line_callback_draw_stroke); } void swirls_line_callback_draw_stroke(void *ptr, int which, - 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; - if (which == SWIRL_TOOL_FUR) { + if (which == SWIRL_TOOL_FUR) + { api->putpixel(canvas, x, y, swirl_stroke_color); - } else { + } + else + { int xx, yy; - for (yy = -1; yy <= 1; yy++) { - for (xx = -1; xx <= 1; xx++) { + + for (yy = -1; yy <= 1; yy++) + { + for (xx = -1; xx <= 1; xx++) + { api->putpixel(canvas, x + xx, y + yy, swirl_stroke_color); } } @@ -385,28 +405,25 @@ void swirls_line_callback_draw_stroke(void *ptr, int which, void swirls_switchin(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas) + int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas) { if (swirls_snapshot == NULL) swirls_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, - canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, canvas->format->Bmask, - canvas->format->Amask); + canvas->format->BitsPerPixel, canvas->format->Rmask, + canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); if (swirls_snapshot != NULL) SDL_BlitSurface(canvas, NULL, swirls_snapshot, NULL); } void swirls_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) { } -double get_angle(int x, int y, int target_x, int target_y) { - return atan2((double) (y - target_y), (double) (x - target_x)); +double get_angle(int x, int y, int target_x, int target_y) +{ + return atan2((double)(y - target_y), (double)(x - target_x)); } @@ -423,6 +440,8 @@ Uint8 swirls_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ return 0; } -void swirls_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 swirls_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) { } diff --git a/magic/src/tint.c b/magic/src/tint.c index 63def0665..1954432c1 100644 --- a/magic/src/tint.c +++ b/magic/src/tint.c @@ -75,13 +75,10 @@ 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, Uint32 disabled_features); @@ -92,15 +89,11 @@ 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); + 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, @@ -109,14 +102,13 @@ void tint_shutdown(magic_api * api); void tint_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); 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); Uint8 tint_accepted_sizes(magic_api * api, int which, int mode); Uint8 tint_default_size(magic_api * api, int which, int mode); -void tint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void tint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 tint_api_version(void) @@ -126,13 +118,13 @@ Uint32 tint_api_version(void) //Load sounds int tint_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) -{int i; +{ + int i; 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]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, tint_snd_filenames[i]); tint_snd_effect[i] = Mix_LoadWAV(fname); } return (1); @@ -148,8 +140,7 @@ 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)); } @@ -160,15 +151,13 @@ 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]))); } @@ -179,8 +168,7 @@ 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; @@ -204,21 +192,18 @@ static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, if (greyValue < thresholdValue) { - api->putpixel(canvas, x, y, - SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b)); + 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)); + 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; @@ -231,8 +216,7 @@ static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, } } -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; @@ -241,8 +225,7 @@ static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, { for (xx = x - tint_RADIUS; xx < x + tint_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, tint_RADIUS) - && !api->touched(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); } @@ -252,12 +235,10 @@ static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, // 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); @@ -284,8 +265,7 @@ 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); @@ -305,8 +285,7 @@ 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) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -327,7 +306,8 @@ void tint_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void tint_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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { tint_r = r; tint_g = g; @@ -335,14 +315,12 @@ void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED } // 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; @@ -370,8 +348,7 @@ void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, } void tint_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) { } @@ -394,8 +371,9 @@ Uint8 tint_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN return 4; } -void tint_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 tint_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) { tint_RADIUS = size * 4; } - diff --git a/magic/src/toothpaste.c b/magic/src/toothpaste.c index e765cbd56..839e12216 100644 --- a/magic/src/toothpaste.c +++ b/magic/src/toothpaste.c @@ -83,30 +83,25 @@ SDL_Surface *toothpaste_get_icon(magic_api * api, int which); char *toothpaste_get_name(magic_api * api, int which); int toothpaste_get_group(magic_api * api, int which); char *toothpaste_get_description(magic_api * api, int which, int mode); -static void do_toothpaste(void *ptr, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y); +static void do_toothpaste(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y); void toothpaste_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); void toothpaste_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 toothpaste_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void toothpaste_shutdown(magic_api * api); void toothpaste_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int toothpaste_requires_colors(magic_api * api, int which); -void toothpaste_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void toothpaste_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void toothpaste_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void toothpaste_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int toothpaste_modes(magic_api * api, int which); int toothpaste_setup_weights(magic_api * api); Uint8 toothpaste_accepted_sizes(magic_api * api, int which, int mode); Uint8 toothpaste_default_size(magic_api * api, int which, int mode); -void toothpaste_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void toothpaste_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 toothpaste_api_version(void) @@ -123,8 +118,7 @@ int toothpaste_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) //Load sounds for (i = 0; i < toothpaste_NUM_TOOLS; i++) { - snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, - toothpaste_snd_filenames[i]); + snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, toothpaste_snd_filenames[i]); toothpaste_snd_effect[i] = Mix_LoadWAV(fname); } @@ -137,13 +131,12 @@ int toothpaste_setup_weights(magic_api * api) //Set up weights pi = acos(0.0) * 2; - if (toothpaste_weights != NULL) { + if (toothpaste_weights != NULL) + { free(toothpaste_weights); } - toothpaste_weights = - (double *) malloc(toothpaste_RADIUS * 2 * toothpaste_RADIUS * 2 * - sizeof(double)); + toothpaste_weights = (double *)malloc(toothpaste_RADIUS * 2 * toothpaste_RADIUS * 2 * sizeof(double)); if (toothpaste_weights == NULL) { return (0); @@ -159,7 +152,7 @@ int toothpaste_setup_weights(magic_api * api) toothpaste_RADIUS) * ((toothpaste_RADIUS * 2) - 1) + (j + toothpaste_RADIUS)] = - ((fabs(atan2((double) (j), (double) (k)))) / pi); + ((fabs(atan2((double)(j), (double)(k)))) / pi); } } } @@ -177,8 +170,7 @@ SDL_Surface *toothpaste_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, - toothpaste_icon_filenames[which]); + snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, toothpaste_icon_filenames[which]); return (IMG_Load(fname)); } @@ -195,16 +187,14 @@ int toothpaste_get_group(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *toothpaste_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *toothpaste_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { return (strdup(gettext_noop(toothpaste_descs[which]))); } // Do the effect: static void do_toothpaste(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -220,18 +210,14 @@ static void do_toothpaste(void *ptr, int which ATTRIBUTE_UNUSED, { for (xx = x - toothpaste_RADIUS; xx < x + toothpaste_RADIUS; xx++) { - if (api->in_circle(xx - x, yy - y, toothpaste_RADIUS) - && !api->touched(xx, yy)) + if (api->in_circle(xx - x, yy - y, toothpaste_RADIUS) && !api->touched(xx, yy)) { api->rgbtohsv(toothpaste_r, toothpaste_g, toothpaste_b, &h, &s, &v); api->hsvtorgb(h, s, toothpaste_weights[(yy - y + toothpaste_RADIUS) * - ((toothpaste_RADIUS * 2) - 1) + (xx - - x + - toothpaste_RADIUS)], - &r, &g, &b); + ((toothpaste_RADIUS * 2) - 1) + (xx - x + toothpaste_RADIUS)], &r, &g, &b); api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, r, g, b)); } @@ -242,12 +228,10 @@ static void do_toothpaste(void *ptr, int which ATTRIBUTE_UNUSED, // Affect the canvas on drag: void toothpaste_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_toothpaste); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_toothpaste); api->playsound(toothpaste_snd_effect[which], (x * 255) / canvas->w, 255); @@ -260,8 +244,7 @@ void toothpaste_drag(magic_api * api, int which, SDL_Surface * canvas, // Affect the canvas on click: void toothpaste_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) { toothpaste_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -272,8 +255,7 @@ void toothpaste_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -298,8 +280,9 @@ void toothpaste_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void toothpaste_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 toothpaste_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) { toothpaste_r = r; toothpaste_g = g; @@ -307,29 +290,23 @@ void toothpaste_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_ } // Use colors: -int toothpaste_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int toothpaste_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } void toothpaste_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 toothpaste_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 toothpaste_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int toothpaste_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT); } @@ -345,7 +322,9 @@ Uint8 toothpaste_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB return 2; } -void toothpaste_set_size(magic_api * api, 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 toothpaste_set_size(magic_api * api, 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) { toothpaste_RADIUS = size * 5; toothpaste_setup_weights(api); diff --git a/magic/src/tornado.c b/magic/src/tornado.c index 69cb8cc93..3f88eb654 100644 --- a/magic/src/tornado.c +++ b/magic/src/tornado.c @@ -63,18 +63,14 @@ typedef struct float x, y; } Point2D; -static void tornado_predrag(magic_api * api, SDL_Surface * canvas, - SDL_Surface * last, int ox, int oy, int x, int y); +static void tornado_predrag(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y); static void tornado_drawbase(magic_api * api, SDL_Surface * canvas); static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int top_x, int top_y, - int minx, int maxx, int bottom_x, int bottom_y, - int final); -static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, - int y); + int minx, int maxx, int bottom_x, int bottom_y, int final); +static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y); static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t); -static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve); +static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve); static void tornado_colorize_cloud(magic_api * api); static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas); Uint32 tornado_api_version(void); @@ -85,26 +81,23 @@ char *tornado_get_name(magic_api * api, int which); int tornado_get_group(magic_api * api, int which); char *tornado_get_description(magic_api * api, int which, int mode); void tornado_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); void tornado_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void tornado_release(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last, int x, int y, - SDL_Rect * update_rect); + SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void tornado_shutdown(magic_api * api); void tornado_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int tornado_requires_colors(magic_api * api, int which); -void tornado_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void tornado_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void tornado_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void tornado_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int tornado_modes(magic_api * api, int which); Uint8 tornado_accepted_sizes(magic_api * api, int which, int mode); Uint8 tornado_default_size(magic_api * api, int which, int mode); -void tornado_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void tornado_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); @@ -125,16 +118,13 @@ int tornado_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) tornado_click_snd = Mix_LoadWAV(fname); */ - snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg", api->data_directory); tornado_release_snd = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png", api->data_directory); tornado_base = IMG_Load(fname); - snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png", api->data_directory); tornado_cloud = IMG_Load(fname); return (1); @@ -151,41 +141,33 @@ SDL_Surface *tornado_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/tornado.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/tornado.png", api->data_directory); return (IMG_Load(fname)); } // Return our names, localized: -char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Tornado"))); } // Return our groups: -int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_ARTISTIC; } // Return our descriptions, localized: -char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED) +char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { - return (strdup - (gettext_noop - ("Click and drag to draw a tornado funnel on your picture."))); + return (strdup(gettext_noop("Click and drag to draw a tornado funnel on your picture."))); } // Affect the canvas on drag: static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, - SDL_Surface * last ATTRIBUTE_UNUSED, int ox, - int oy, int x, int y) + SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y) { if (x < tornado_min_x) tornado_min_x = x; @@ -219,8 +201,7 @@ static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED, } void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, - int x, int y, SDL_Rect * update_rect) + SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect) { tornado_predrag(api, canvas, last, ox, oy, x, y); @@ -233,8 +214,7 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, /* Draw the base and the stalk (low-quality) for now: */ tornado_drawstalk(api, canvas, last, - x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, - tornado_bottom_y, !(api->button_down())); + x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, !(api->button_down())); tornado_drawbase(api, canvas); @@ -246,8 +226,7 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, // Affect the canvas on click: void tornado_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) { tornado_min_x = x; tornado_max_x = x; @@ -266,8 +245,7 @@ void tornado_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, // Affect the canvas on release: void tornado_release(magic_api * api, int which 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) { /* Don't let tornado be too low compared to base: */ @@ -287,8 +265,7 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED, /* Draw high-quality stalk, and tornado: */ - tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x, - tornado_bottom_x, tornado_bottom_y, 1); + tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, 1); tornado_drawtornado(api, canvas, x, y); @@ -304,8 +281,7 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED, } -static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, - int y) +static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y) { SDL_Surface *aux_surf; SDL_Rect dest; @@ -318,8 +294,7 @@ static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, SDL_FreeSurface(aux_surf); } -static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, - SDL_Surface * canvas) +static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas) { SDL_Rect dest; @@ -332,19 +307,17 @@ static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas) { Uint8 r, g, b, a; - float f = (float) rand() * 255 / RAND_MAX; + float f = (float)rand() * 255 / RAND_MAX; SDL_GetRGBA(pixel, canvas->format, &r, &g, &b, &a); return (SDL_MapRGBA(canvas->format, (tornado_r + r + (Uint8) f * 2) / 4, - (tornado_g + g + (Uint8) f * 2) / 4, - (tornado_b + b + (Uint8) f * 2) / 4, a)); + (tornado_g + g + (Uint8) f * 2) / 4, (tornado_b + b + (Uint8) f * 2) / 4, a)); } static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int top_x, int top_y, - int minx, int maxx, int bottom_x, int bottom_y, - int final) + int minx, int maxx, int bottom_x, int bottom_y, int final) { Point2D control_points[4]; Point2D *curve; @@ -426,34 +399,23 @@ static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, /* The body of the tornado: 3x 1y rotation + some random particles */ for (p = dest.x; p < dest.x + dest.w; p++) { - if ((float) rand() * 100 / RAND_MAX > 10) + if ((float)rand() * 100 / RAND_MAX > 10) { - api->putpixel(canvas, p, dest.y, - api->getpixel(last, - dest.x + (p - dest.x + rotation) % dest.w, - dest.y)); + api->putpixel(canvas, p, dest.y, api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y)); } else { api->putpixel(canvas, p, dest.y, - tornado_mess(api->getpixel(last, - dest.x + (p - dest.x + - rotation) % dest.w, - dest.y), canvas)); + tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y), canvas)); } } /* Some random particles flying around the tornado */ - for (p = dest.x - dest.w * 20 / 100; - p < dest.x + dest.w + dest.w * 20 / 100; p++) + for (p = dest.x - dest.w * 20 / 100; p < dest.x + dest.w + dest.w * 20 / 100; p++) { - if ((float) rand() * 100 / RAND_MAX < 5 - && ((p < dest.x) || (p > dest.w))) + if ((float)rand() * 100 / RAND_MAX < 5 && ((p < dest.x) || (p > dest.w))) api->putpixel(canvas, p, dest.y, - tornado_mess(api->getpixel(last, - dest.x + (p - dest.x + - rotation) % dest.w, - dest.y), canvas)); + tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y), canvas)); } } @@ -480,7 +442,8 @@ void tornado_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Record the color from Tux Paint: void tornado_set_color(magic_api * api, 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 * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, + SDL_Rect * update_rect ATTRIBUTE_UNUSED) { tornado_r = r; tornado_g = g; @@ -490,8 +453,7 @@ void tornado_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface } // Use colors: -int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 1; } @@ -546,8 +508,7 @@ static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t) */ -static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, - Point2D * curve) +static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve) { float dt; int i; @@ -570,9 +531,7 @@ static void tornado_colorize_cloud(magic_api * api) /* Create a surface to render into: */ - amask = - ~(tornado_cloud->format->Rmask | tornado_cloud->format-> - Gmask | tornado_cloud->format->Bmask); + amask = ~(tornado_cloud->format->Rmask | tornado_cloud->format->Gmask | tornado_cloud->format->Bmask); tornado_cloud_colorized = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -580,8 +539,7 @@ static void tornado_colorize_cloud(magic_api * api) tornado_cloud->h, tornado_cloud->format->BitsPerPixel, tornado_cloud->format->Rmask, - tornado_cloud->format->Gmask, - tornado_cloud->format->Bmask, amask); + tornado_cloud->format->Gmask, tornado_cloud->format->Bmask, amask); /* Render the new cloud: */ @@ -592,14 +550,11 @@ static void tornado_colorize_cloud(magic_api * api) { for (x = 0; x < tornado_cloud->w; x++) { - SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format, - &r, &g, &b, &a); + SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format, &r, &g, &b, &a); api->putpixel(tornado_cloud_colorized, x, y, SDL_MapRGBA(tornado_cloud_colorized->format, - (tornado_r + r * 2) / 3, - (tornado_g + g * 2) / 3, - (tornado_b + b * 2) / 3, a)); + (tornado_r + r * 2) / 3, (tornado_g + g * 2) / 3, (tornado_b + b * 2) / 3, a)); } } @@ -608,20 +563,17 @@ static void tornado_colorize_cloud(magic_api * api) } void tornado_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 tornado_switchout(magic_api * api, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { api->stopsound(); } -int tornado_modes(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int tornado_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (MODE_PAINT_WITH_PREVIEW); } @@ -637,6 +589,8 @@ Uint8 tornado_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE return 0; } -void tornado_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 tornado_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) { } diff --git a/magic/src/tv.c b/magic/src/tv.c index 3448fc18c..8972488b6 100644 --- a/magic/src/tv.c +++ b/magic/src/tv.c @@ -36,7 +36,8 @@ static int tv_radius = 16; -enum { +enum +{ TV_TOOL_TV_CLASSIC, TV_TOOL_TV_BRIGHT, NUM_TV_TOOLS @@ -55,16 +56,12 @@ int tv_get_group(magic_api * api, int which); char *tv_get_description(magic_api * api, int which, int mode); int tv_requires_colors(magic_api * api, int which); void tv_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 tv_shutdown(magic_api * api); -void tv_paint_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); -void tv_do_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, - SDL_Surface * snapshot, int x, int y); +void tv_paint_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); +void tv_do_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y); void tv_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 tv_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void tv_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); @@ -72,7 +69,8 @@ void tv_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int tv_modes(magic_api * api, int which); Uint8 tv_accepted_sizes(magic_api * api, int which, int mode); Uint8 tv_default_size(magic_api * api, int which, int mode); -void tv_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void tv_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); // Housekeeping functions @@ -83,7 +81,8 @@ Uint32 tv_api_version(void) } void tv_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 * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, + Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { //get the colors from API and store it in structure } @@ -92,8 +91,7 @@ int tv_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/tv.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/tv.ogg", api->data_directory); tv_snd = Mix_LoadWAV(fname); return (1); @@ -108,8 +106,7 @@ SDL_Surface *tv_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/tv.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/tv.png", api->data_directory); return (IMG_Load(fname)); } @@ -127,21 +124,15 @@ int tv_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) return MAGIC_TYPE_DISTORTS; } -char *tv_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *tv_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) - return - strdup(gettext_noop - ("Click and drag to make parts of your picture look like they are on television.")); + return strdup(gettext_noop("Click and drag to make parts of your picture look like they are on television.")); else - return - strdup(gettext_noop - ("Click to make your picture look like it's on television.")); + return strdup(gettext_noop("Click to make your picture look like it's on television.")); } -int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } @@ -149,8 +140,7 @@ int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED, void tv_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) { } @@ -162,8 +152,7 @@ void tv_shutdown(magic_api * api ATTRIBUTE_UNUSED) // Interactivity functions void tv_do_tv(void *ptr_to_api, int which_tool, - 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_to_api; int r, g, b, i; @@ -178,11 +167,14 @@ void tv_do_tv(void *ptr_to_api, int which_tool, the original "TV" effect as a stylistic way to darken parts of their picture, so we offer two tools (brighter, and classic). -bjk 2023.04.22 */ - if (which_tool == TV_TOOL_TV_BRIGHT) { + if (which_tool == TV_TOOL_TV_BRIGHT) + { r = r8 * 2; g = g8 * 2; b = b8 * 2; - } else { + } + else + { r = r8; g = g8; b = b8; @@ -220,8 +212,7 @@ void tv_do_tv(void *ptr_to_api, int which_tool, } void tv_paint_tv(void *ptr_to_api, int which_tool, - SDL_Surface * canvas, - SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y) { int i, j; magic_api *api = (magic_api *) ptr_to_api; @@ -241,8 +232,7 @@ void tv_paint_tv(void *ptr_to_api, int which_tool, } void tv_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(api, which, canvas, snapshot, ox, oy, x, y, 1, tv_paint_tv); @@ -254,8 +244,7 @@ void tv_drag(magic_api * api, int which, SDL_Surface * canvas, } void tv_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_FULLSCREEN) { @@ -279,15 +268,13 @@ void tv_click(magic_api * api, int which, int mode, } void tv_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, - int mode ATTRIBUTE_UNUSED, - SDL_Surface * canvas ATTRIBUTE_UNUSED) + int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { } void tv_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) { } @@ -311,7 +298,9 @@ Uint8 tv_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS return 4; } -void tv_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 tv_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) { tv_radius = size * 4; } diff --git a/magic/src/waves.c b/magic/src/waves.c index d5cdf2cc9..6102e9c8f 100644 --- a/magic/src/waves.c +++ b/magic/src/waves.c @@ -48,8 +48,7 @@ char *waves_get_name(magic_api * api, int which); int waves_get_group(magic_api * api, int which); char *waves_get_description(magic_api * api, int which, int mode); void waves_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); void waves_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void waves_release(magic_api * api, int which, SDL_Surface * canvas, @@ -58,14 +57,13 @@ void waves_shutdown(magic_api * api); void waves_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int waves_requires_colors(magic_api * api, int which); -void waves_switchin(magic_api * api, int which, int mode, - SDL_Surface * canvas); -void waves_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void waves_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); +void waves_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int waves_modes(magic_api * api, int which); Uint8 waves_accepted_sizes(magic_api * api, int which, int mode); Uint8 waves_default_size(magic_api * api, int which, int mode); -void waves_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void waves_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 waves_api_version(void) { @@ -78,12 +76,10 @@ int waves_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/waves.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/waves.ogg", api->data_directory); waves_snd[0] = Mix_LoadWAV(fname); - snprintf(fname, sizeof(fname), "%ssounds/magic/wavelet.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/wavelet.ogg", api->data_directory); waves_snd[1] = Mix_LoadWAV(fname); @@ -102,18 +98,15 @@ SDL_Surface *waves_get_icon(magic_api * api, int which) char fname[1024]; if (!which) - snprintf(fname, sizeof(fname), "%simages/magic/waves.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/waves.png", api->data_directory); else - snprintf(fname, sizeof(fname), "%simages/magic/wavelet.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/wavelet.png", api->data_directory); return (IMG_Load(fname)); } // Return our group (both the same): -int waves_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int waves_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } @@ -128,8 +121,7 @@ char *waves_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our descriptions, localized: -char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, - int mode ATTRIBUTE_UNUSED) +char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { if (!which) return (strdup @@ -143,8 +135,7 @@ char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, void waves_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas, SDL_Surface * last, - int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, - int y, SDL_Rect * update_rect) + int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { int xx, yy; SDL_Rect src, dest; @@ -202,8 +193,7 @@ void waves_drag(magic_api * api ATTRIBUTE_UNUSED, int which, // Affect the canvas on click: void waves_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) { waves_drag(api, which, canvas, last, x, y, x, y, update_rect); api->playsound(waves_snd[which], 128, 255); @@ -214,8 +204,7 @@ void waves_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) + int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -229,27 +218,26 @@ void waves_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void waves_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) +void waves_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) { } // Use colors: -int waves_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int waves_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void waves_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 waves_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) { } @@ -269,6 +257,8 @@ Uint8 waves_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U return 0; } -void waves_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 waves_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) { } diff --git a/magic/src/xor.c b/magic/src/xor.c index 5ff3789c5..eef8a200c 100644 --- a/magic/src/xor.c +++ b/magic/src/xor.c @@ -44,28 +44,25 @@ int xor_get_group(magic_api * api, int which); char *xor_get_description(magic_api * api, int which, int mode); void xor_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); void xor_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 xor_release(magic_api * api, int which, - 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 xor_shutdown(magic_api * api); void xor_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect); int xor_requires_colors(magic_api * api, int which); void xor_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); -void xor_switchout(magic_api * api, int which, int mode, - SDL_Surface * canvas); +void xor_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int xor_modes(magic_api * api, int which); Uint8 xor_accepted_sizes(magic_api * api, int which, int mode); Uint8 xor_default_size(magic_api * api, int which, int mode); -void xor_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect); +void xor_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, + SDL_Rect * update_rect); Uint32 xor_api_version(void) @@ -77,8 +74,7 @@ int xor_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%ssounds/magic/xor.ogg", - api->data_directory); + snprintf(fname, sizeof(fname), "%ssounds/magic/xor.ogg", api->data_directory); xor_snd = Mix_LoadWAV(fname); return (1); @@ -93,38 +89,31 @@ SDL_Surface *xor_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED) { char fname[1024]; - snprintf(fname, sizeof(fname), "%simages/magic/xor.png", - api->data_directory); + snprintf(fname, sizeof(fname), "%simages/magic/xor.png", api->data_directory); return (IMG_Load(fname)); } -char *xor_get_name(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +char *xor_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return (strdup(gettext_noop("Xor Colors"))); } -int xor_get_group(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int xor_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_COLOR_FILTERS; } -char *xor_get_description(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED, int mode) +char *xor_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) { if (mode == MODE_PAINT) return (strdup(gettext_noop("Click and drag to draw a XOR effect"))); else - return (strdup - (gettext_noop - ("Click to draw a XOR effect on the whole picture"))); + return (strdup(gettext_noop("Click to draw a XOR effect on the whole picture"))); } static void do_xor(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; Uint8 r, g, b, xor; @@ -134,17 +123,16 @@ static void do_xor(void *ptr, int which ATTRIBUTE_UNUSED, SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r, &g, &b); api->rgbtohsv(r, g, b, &hue, &sat, &val); if (sat == 0) - xor = (2 * (int) hue + (x ^ y)) % 360; + xor = (2 * (int)hue + (x ^ y)) % 360; else - xor = ((int) hue + (x ^ y)) % 360; + xor = ((int)hue + (x ^ y)) % 360; api->hsvtorgb(xor, 1, 1, &r, &g, &b); pixel = SDL_MapRGB(canvas->format, r, g, b); api->putpixel(canvas, x, y, pixel); } static void do_xor_circle(void *ptr, int which ATTRIBUTE_UNUSED, - SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y) { magic_api *api = (magic_api *) ptr; int xx, yy; @@ -163,11 +151,9 @@ static void do_xor_circle(void *ptr, int which ATTRIBUTE_UNUSED, } void xor_drag(magic_api * api, int which, SDL_Surface * canvas, - SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, - int y, SDL_Rect * update_rect) + SDL_Surface * last ATTRIBUTE_UNUSED, 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_xor_circle); + api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_xor_circle); if (ox > x) { @@ -193,8 +179,7 @@ void xor_drag(magic_api * api, int which, SDL_Surface * canvas, } void xor_click(magic_api * api, int which, int mode, - SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, - int x, int y, SDL_Rect * update_rect) + SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect) { if (mode == MODE_PAINT) xor_drag(api, which, canvas, last, x, y, x, y, update_rect); @@ -217,8 +202,7 @@ void xor_click(magic_api * api, int which, int mode, void xor_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) + int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } @@ -229,25 +213,23 @@ void xor_shutdown(magic_api * api ATTRIBUTE_UNUSED) } void xor_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 * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, + Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED) { } -int xor_requires_colors(magic_api * api ATTRIBUTE_UNUSED, - int which ATTRIBUTE_UNUSED) +int xor_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } void xor_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 xor_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) { } @@ -270,7 +252,9 @@ Uint8 xor_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNU return 4; } -void xor_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 xor_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) { xor_radius = size * 4; } diff --git a/src/android_assets.c b/src/android_assets.c index 0d2f0caaf..0499d20c4 100644 --- a/src/android_assets.c +++ b/src/android_assets.c @@ -32,15 +32,15 @@ char *get_nativelibdir() return nativelibdir; } -void load_assets_dir(char *dirname, tp_ftw_str ** ffilenames, - unsigned *num_file_names) +void load_assets_dir(char *dirname, tp_ftw_str ** ffilenames, unsigned *num_file_names) { AAssetDir *assetDir = AAssetManager_openDir(asset_manager, dirname); - const char *filename = (const char *) NULL; + const char *filename = (const char *)NULL; tp_ftw_str *filenames = NULL; unsigned max_file_names = 0; int fulllen = 0; + *num_file_names = 0; @@ -67,12 +67,7 @@ void load_assets_dir(char *dirname, tp_ftw_str ** ffilenames, *ffilenames = filenames; } -JNIEXPORT jboolean Java_org_tuxpaint_tuxpaintActivity_managertojni(JNIEnv * - env, - jclass - clazz, - jobject - mgr) +JNIEXPORT jboolean Java_org_tuxpaint_tuxpaintActivity_managertojni(JNIEnv * env, jclass clazz, jobject mgr) { asset_manager = AAssetManager_fromJava(env, mgr); @@ -82,14 +77,10 @@ JNIEXPORT jboolean Java_org_tuxpaint_tuxpaintActivity_managertojni(JNIEnv * return 1; } -JNIEXPORT void Java_org_tuxpaint_tuxpaintActivity_setnativelibdir(JNIEnv * - env, - jclass - clazz, - jstring - path) +JNIEXPORT void Java_org_tuxpaint_tuxpaintActivity_setnativelibdir(JNIEnv * env, jclass clazz, jstring path) { const char *cpath = (*env)->GetStringUTFChars(env, path, NULL); + nativelibdir = strdup(cpath); (*env)->ReleaseStringUTFChars(env, path, cpath); } @@ -102,8 +93,7 @@ void load_brushes_from_assets(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, tp_ftw_str * files, - unsigned count, - const char *restrict const locale)) + unsigned count, const char *restrict const locale)) { unsigned num_file_names = 0; char *dir = "data/brushes"; @@ -127,10 +117,10 @@ void load_from_assets(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, tp_ftw_str * files, - unsigned count, - const char *restrict const locale)) + unsigned count, const char *restrict const locale)) { unsigned num_file_names = 0; + // char * dir = "data/stamps/cartoon/tux"; char buf[TP_FTW_PATHSIZE]; unsigned dirlen = strlen(dirname); @@ -140,6 +130,5 @@ void load_from_assets(SDL_Surface * screen, SDL_Texture * texture, tp_ftw_str *filenames = NULL; load_assets_dir(dirname, &filenames, &num_file_names); - fn(screen, texture, renderer, dirname, dirlen, filenames, num_file_names, - NULL); + fn(screen, texture, renderer, dirname, dirlen, filenames, num_file_names, NULL); } diff --git a/src/android_assets.h b/src/android_assets.h index 97d722f7c..0f33cdf68 100644 --- a/src/android_assets.h +++ b/src/android_assets.h @@ -38,8 +38,7 @@ void load_brushes_from_assets(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, tp_ftw_str * files, - unsigned count, - const char *restrict const locale)); + unsigned count, const char *restrict const locale)); void load_from_assets(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *dirname, @@ -47,24 +46,12 @@ void load_from_assets(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, tp_ftw_str * files, - unsigned count, - const char *restrict const locale)); + unsigned count, const char *restrict const locale)); -void load_assets_dir(char *dirname, tp_ftw_str ** ffilenames, - unsigned *num_file_names); +void load_assets_dir(char *dirname, tp_ftw_str ** ffilenames, unsigned *num_file_names); -JNIEXPORT jboolean Java_org_tuxpaint_tuxpaintActivity_managertojni(JNIEnv * - env, - jclass - clazz, - jobject - mgr); +JNIEXPORT jboolean Java_org_tuxpaint_tuxpaintActivity_managertojni(JNIEnv * env, jclass clazz, jobject mgr); -JNIEXPORT void Java_org_tuxpaint_tuxpaintActivity_setnativelibdir(JNIEnv * - env, - jclass - clazz, - jstring - path); +JNIEXPORT void Java_org_tuxpaint_tuxpaintActivity_setnativelibdir(JNIEnv * env, jclass clazz, jstring path); #endif diff --git a/src/android_mbstowcs.c b/src/android_mbstowcs.c index fcba44fe4..3c5c9bdaa 100644 --- a/src/android_mbstowcs.c +++ b/src/android_mbstowcs.c @@ -33,6 +33,7 @@ size_t mbstowcs(wchar_t *__restrict pwcs, const char *__restrict s, size_t n) { int length = strnlen(s, n); + // w is the index of pwcs, s is the index of s int w = 0, c = 0; @@ -41,9 +42,10 @@ size_t mbstowcs(wchar_t *__restrict pwcs, const char *__restrict s, size_t n) pwcs[w] = '\0'; char first = s[c]; int len = 0; + if ((first & 0x80) == 0) { - pwcs[w] = (wchar_t) s[c]; + pwcs[w] = (wchar_t)s[c]; len = 1; } else if ((first & 0xe0) == 0xc0) diff --git a/src/android_print.c b/src/android_print.c index f367a1b5c..476cc4c28 100644 --- a/src/android_print.c +++ b/src/android_print.c @@ -34,17 +34,14 @@ int IsPrinterAvailable(void) { JNIEnv *mEnv = Android_JNI_GetEnv(); - jclass mPrintHelperClass = - (*mEnv)->FindClass(mEnv, "androidx/print/PrintHelper"); + jclass mPrintHelperClass = (*mEnv)->FindClass(mEnv, "androidx/print/PrintHelper"); if (mPrintHelperClass == NULL) return 0; - jmethodID mSupportMethod = - (*mEnv)->GetStaticMethodID(mEnv, mPrintHelperClass, "systemSupportsPrint", - "()Z"); - jboolean support = - (*mEnv)->CallStaticBooleanMethod(mEnv, mPrintHelperClass, mSupportMethod); + jmethodID mSupportMethod = (*mEnv)->GetStaticMethodID(mEnv, mPrintHelperClass, "systemSupportsPrint", + "()Z"); + jboolean support = (*mEnv)->CallStaticBooleanMethod(mEnv, mPrintHelperClass, mSupportMethod); return support ? 1 : 0; } @@ -56,49 +53,41 @@ const char *SurfacePrint(SDL_Surface * surface) { JNIEnv *mEnv = Android_JNI_GetEnv(); jclass mBitmapClass = (*mEnv)->FindClass(mEnv, "android/graphics/Bitmap"); - jmethodID mCreateMethod = - (*mEnv)->GetStaticMethodID(mEnv, mBitmapClass, "createBitmap", - "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); - jintArray mSurfaceArray = - (*mEnv)->NewIntArray(mEnv, surface->w * surface->h); - (*mEnv)->SetIntArrayRegion(mEnv, mSurfaceArray, 0, surface->w * surface->h, - surface->pixels); - jclass mConfigClass = - (*mEnv)->FindClass(mEnv, "android/graphics/Bitmap$Config"); - jfieldID mConfigField = - (*mEnv)->GetStaticFieldID(mEnv, mConfigClass, "ARGB_8888", - "Landroid/graphics/Bitmap$Config;"); - jobject mConfig = - (*mEnv)->GetStaticObjectField(mEnv, mConfigClass, mConfigField); - jobject mBitMap = - (*mEnv)->CallStaticObjectMethod(mEnv, mBitmapClass, mCreateMethod, - mSurfaceArray, surface->w, surface->h, - mConfig); + jmethodID mCreateMethod = (*mEnv)->GetStaticMethodID(mEnv, mBitmapClass, "createBitmap", + "([IIILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); + jintArray mSurfaceArray = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h); + + (*mEnv)->SetIntArrayRegion(mEnv, mSurfaceArray, 0, surface->w * surface->h, surface->pixels); + jclass mConfigClass = (*mEnv)->FindClass(mEnv, "android/graphics/Bitmap$Config"); + jfieldID mConfigField = (*mEnv)->GetStaticFieldID(mEnv, mConfigClass, "ARGB_8888", + "Landroid/graphics/Bitmap$Config;"); + jobject mConfig = (*mEnv)->GetStaticObjectField(mEnv, mConfigClass, mConfigField); + jobject mBitMap = (*mEnv)->CallStaticObjectMethod(mEnv, mBitmapClass, mCreateMethod, + mSurfaceArray, surface->w, surface->h, + mConfig); jobject mContext = (jobject) SDL_AndroidGetActivity(); jclass mPrintClass = (*mEnv)->FindClass(mEnv, "androidx/print/PrintHelper"); + // sometimes android v4 support library may be not ready if (mPrintClass == NULL) return "There is no androidX support library."; jmethodID mInitMethod = (*mEnv)->GetMethodID(mEnv, mPrintClass, "", "(Landroid/content/Context;)V"); - jobject mPrint = - (*mEnv)->NewObject(mEnv, mPrintClass, mInitMethod, mContext); - jmethodID mPrintMethod = - (*mEnv)->GetMethodID(mEnv, mPrintClass, "printBitmap", - "(Ljava/lang/String;Landroid/graphics/Bitmap;)V"); + jobject mPrint = (*mEnv)->NewObject(mEnv, mPrintClass, mInitMethod, mContext); + jmethodID mPrintMethod = (*mEnv)->GetMethodID(mEnv, mPrintClass, "printBitmap", + "(Ljava/lang/String;Landroid/graphics/Bitmap;)V"); /* Thanks to n.collins for the explaination on the int signature on https://stackoverflow.com/questions/13468041/android-how-to-call-java-method-from-jni-with-int-and-int-parameters --Pere */ - jmethodID msetScaleMode = - (*mEnv)->GetMethodID(mEnv, mPrintClass, "setScaleMode", "(I)V"); - jfieldID mScaleModeField = - (*mEnv)->GetStaticFieldID(mEnv, mPrintClass, "SCALE_MODE_FIT", "I"); - jint mScaleModeInt = - (*mEnv)->GetStaticIntField(mEnv, mPrintClass, mScaleModeField); + jmethodID msetScaleMode = (*mEnv)->GetMethodID(mEnv, mPrintClass, "setScaleMode", "(I)V"); + jfieldID mScaleModeField = (*mEnv)->GetStaticFieldID(mEnv, mPrintClass, "SCALE_MODE_FIT", "I"); + jint mScaleModeInt = (*mEnv)->GetStaticIntField(mEnv, mPrintClass, mScaleModeField); + (*mEnv)->CallVoidMethod(mEnv, mPrint, msetScaleMode, mScaleModeInt); jstring mString = (*mEnv)->NewStringUTF(mEnv, "TuxPaint"); + (*mEnv)->CallVoidMethod(mEnv, mPrint, mPrintMethod, mString, mBitMap); // clean up diff --git a/src/cursor.c b/src/cursor.c index 8a6aedb8b..82aaeaf2e 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -34,8 +34,7 @@ SDL_Cursor *cursor_hand, *cursor_arrow, *cursor_watch, *cursor_up, *cursor_down, *cursor_tiny, *cursor_crosshair, - *cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate, - *cursor_pipette; + *cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate, *cursor_pipette; #ifdef NOKIA_770 int hide_cursor = 1; diff --git a/src/cursor.h b/src/cursor.h index 3d6be0e01..edbb64a6f 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -70,8 +70,7 @@ extern SDL_Cursor *cursor_hand, *cursor_arrow, *cursor_watch, *cursor_up, *cursor_down, *cursor_tiny, *cursor_crosshair, - *cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate, - *cursor_pipette; + *cursor_brush, *cursor_wand, *cursor_insertion, *cursor_rotate, *cursor_pipette; extern int no_fancy_cursors, hide_cursor; diff --git a/src/dirwalk.c b/src/dirwalk.c index a85368481..72ee57bd3 100644 --- a/src/dirwalk.c +++ b/src/dirwalk.c @@ -82,8 +82,7 @@ extern char *strcasestr(const char *haystack, const char *needle); void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, - tp_ftw_str * files, unsigned i, - const char *restrict const locale) + tp_ftw_str * files, unsigned i, const char *restrict const locale) { dirlen = dirlen; @@ -153,10 +152,8 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, } if (font) { - const char *restrict const family = - TuxPaint_Font_FontFaceFamilyName(font); - const char *restrict const style = - TuxPaint_Font_FontFaceStyleName(font); + const char *restrict const family = TuxPaint_Font_FontFaceFamilyName(font); + const char *restrict const style = TuxPaint_Font_FontFaceStyleName(font); #ifdef DEBUG @@ -165,22 +162,19 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, int numfaces = TTF_FontFaces(font->ttf_font); if (numfaces != 1) - printf("%s:%d - Found %d faces in %s, %s, %s\n", __FILE__, - __LINE__, numfaces, files[i].str, family, style); + printf("%s:%d - Found %d faces in %s, %s, %s\n", __FILE__, __LINE__, numfaces, files[i].str, family, style); - printf("%s:%d - success: tpf: 0x%x tpf->ttf_font: 0x%x\n", __FILE__, __LINE__, (unsigned int) (intptr_t) font, (unsigned int) (intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64 + printf("%s:%d - success: tpf: 0x%x tpf->ttf_font: 0x%x\n", __FILE__, __LINE__, (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64 } #ifndef NO_SDLPANGO else printf("%s:%d - success: tpf: 0x%x tpf->pango_context: 0x%x\n", - __FILE__, __LINE__, (unsigned int) (intptr_t) font, - (unsigned int) (intptr_t) font->pango_context); + __FILE__, __LINE__, (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->pango_context); #endif #endif // These fonts crash Tux Paint via a library bug. - int blacklisted = !strcmp("Zapfino", family) - || !strcmp("Elvish Ring NFI", family); + int blacklisted = !strcmp("Zapfino", family) || !strcmp("Elvish Ring NFI", family); // First, the blacklist. We list font families that can crash Tux Paint // via bugs in the SDL_ttf library. We also test fonts to be sure that @@ -201,8 +195,7 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, // impossible for a user to type ASCII letters. // // Most translators should use scoring instead. - if (!charset_works(font, gettext("qx")) - || !charset_works(font, gettext("QX"))) + if (!charset_works(font, gettext("qx")) || !charset_works(font, gettext("QX"))) blacklisted = 1; if (!blacklisted) @@ -210,12 +203,9 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, if (num_font_styles == num_font_styles_max) { num_font_styles_max = num_font_styles_max * 5 / 4 + 30; - user_font_styles = - realloc(user_font_styles, - num_font_styles_max * sizeof *user_font_styles); + user_font_styles = realloc(user_font_styles, num_font_styles_max * sizeof *user_font_styles); } - user_font_styles[num_font_styles] = - malloc(sizeof *user_font_styles[num_font_styles]); + user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]); user_font_styles[num_font_styles]->directory = strdup(dir); user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below) user_font_styles[num_font_styles]->family = strdup(family); @@ -230,52 +220,46 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, // Translators should do whatever is needed to put crummy fonts last. user_font_styles[num_font_styles]->score += - charset_works( - font, /* distinct uppercase and lowercase (e.g., 'o' vs. 'O') */ gettext("oO") + charset_works(font, /* distinct uppercase and lowercase (e.g., 'o' vs. 'O') */ gettext("oO") ); // common punctuation (e.g., '?', '!', '.', ',', etc.) user_font_styles[num_font_styles]->score += - charset_works( - font, /* common punctuation (e.g., '?', '!', '.', ',', etc.) */ gettext(",.?!") + charset_works(font, /* common punctuation (e.g., '?', '!', '.', ',', etc.) */ gettext(",.?!") ); user_font_styles[num_font_styles]->score += - charset_works( - font, /* uncommon punctuation (e.g., '@', '#', '*', etc.) */ gettext("`\%_@$~#{<(^&*") + charset_works(font, /* uncommon punctuation (e.g., '@', '#', '*', etc.) */ gettext("`\%_@$~#{<(^&*") ); user_font_styles[num_font_styles]->score += - charset_works( - font, /* digits (e.g., '0', '1' and '7') */ gettext("017") + charset_works(font, /* digits (e.g., '0', '1' and '7') */ gettext("017") ); user_font_styles[num_font_styles]->score += - charset_works( - font, /* distinct circle-like characters (e.g., 'O' (capital oh) vs. '0' (zero)) */ gettext("O0") + charset_works(font, /* distinct circle-like characters (e.g., 'O' (capital oh) vs. '0' (zero)) */ + gettext("O0") ); user_font_styles[num_font_styles]->score += - charset_works( - font, /* distinct line-like characters (e.g., 'l' (lowercase elle) vs. '1' (one) vs. 'I' (capital aye)) */ gettext("1Il|") - ); + charset_works(font, + /* distinct line-like characters (e.g., 'l' (lowercase elle) vs. '1' (one) vs. 'I' (capital aye)) */ + gettext("1Il|") + ); // Translation spares - + user_font_styles[num_font_styles]->score += - // If neccessary, translate any of following strings using at least - // two locale specific characters required to render your language. - // Then, the scores for those fonts having such characters will increase. - // - // You can use two different weight for scoring, 1 or 9, according - // to the importance. + // If neccessary, translate any of following strings using at least + // two locale specific characters required to render your language. + // Then, the scores for those fonts having such characters will increase. + // + // You can use two different weight for scoring, 1 or 9, according + // to the importance. charset_works(font, gettext("<1>spare-1a")); - user_font_styles[num_font_styles]->score += - charset_works(font, gettext("<1>spare-1b")); - user_font_styles[num_font_styles]->score += - charset_works(font, gettext("<9>spare-9a")) * 9; - user_font_styles[num_font_styles]->score += - charset_works(font, gettext("<9>spare-9b")) * 9; + user_font_styles[num_font_styles]->score += charset_works(font, gettext("<1>spare-1b")); + user_font_styles[num_font_styles]->score += charset_works(font, gettext("<9>spare-9a")) * 9; + user_font_styles[num_font_styles]->score += charset_works(font, gettext("<9>spare-9b")) * 9; // this really should be dynamic, avoiding the need for a special build #ifdef OLPC_XO @@ -292,8 +276,7 @@ void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, else { #ifdef DEBUG - fprintf(stderr, "Font is too defective: %s, %s, %s\n", files[i].str, - family, style); + fprintf(stderr, "Font is too defective: %s, %s, %s\n", files[i].str, family, style); #endif } TuxPaint_Font_CloseFont(font); @@ -349,9 +332,7 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, dir, unsigned dirlen, tp_ftw_str * files, unsigned count, - const char *restrict const - locale), - const char *restrict const locale) + const char *restrict const locale), const char *restrict const locale) { DIR *d; unsigned num_file_names = 0; @@ -362,6 +343,7 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, tp_ftw_str *dir_names = NULL; int d_namlen; int add_rsrc; + #ifdef __ANDROID__ unsigned dlen; #endif @@ -532,12 +514,10 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, #else #ifdef __ANDROID__ if (dlen != dirlen) /* First case only happens in Android files coming from assets */ - fn(screen, texture, renderer, di, dlen, file_names, num_file_names, - locale); + fn(screen, texture, renderer, di, dlen, file_names, num_file_names, locale); else #endif - fn(screen, texture, renderer, dir, dirlen, file_names, num_file_names, - locale); + fn(screen, texture, renderer, dir, dirlen, file_names, num_file_names, locale); #endif } @@ -546,10 +526,8 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str); while (num_dir_names--) { - memcpy(dir + dirlen, dir_names[num_dir_names].str, - dir_names[num_dir_names].len + 1); - tp_ftw(screen, texture, renderer, dir, - dirlen + dir_names[num_dir_names].len, rsrc, fn, locale); + memcpy(dir + dirlen, dir_names[num_dir_names].str, dir_names[num_dir_names].len + 1); + tp_ftw(screen, texture, renderer, dir, dirlen + dir_names[num_dir_names].len, rsrc, fn, locale); free(dir_names[num_dir_names].str); } free(dir_names); diff --git a/src/dirwalk.h b/src/dirwalk.h index 0fecd99de..65aa3dbcf 100644 --- a/src/dirwalk.h +++ b/src/dirwalk.h @@ -49,8 +49,7 @@ typedef struct tp_ftw_str void loadfont_callback(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *restrict const dir, unsigned dirlen, - tp_ftw_str * files, unsigned i, - const char *restrict const locale); + tp_ftw_str * files, unsigned i, const char *restrict const locale); int compare_ftw_str(const void *v1, const void *v2); void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, char *restrict const dir, @@ -62,7 +61,6 @@ void tp_ftw(SDL_Surface * screen, SDL_Texture * texture, tp_ftw_str * files, unsigned count, const char *restrict const - locale), - const char *restrict const locale); + locale), const char *restrict const locale); #endif diff --git a/src/fill.c b/src/fill.c index 8af5877a4..0623bcd26 100644 --- a/src/fill.c +++ b/src/fill.c @@ -82,7 +82,7 @@ sdf_point sdf_pt_empty = { 9999, 9999 }; typedef struct sdf_grid_s { - sdf_point * * grid; + sdf_point **grid; int w, h; } sdf_grid; @@ -96,14 +96,10 @@ int global_extent_x1, global_extent_y1, global_extent_x2, global_extent_y2; int global_prog_anim; double colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2); -Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, - double pct); +Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct); void simulate_flood_fill_outside_check(SDL_Surface * screen, - SDL_Texture * texture, - SDL_Renderer * renderer, int x, int y, - int y_outside); -void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, - Uint32 draw_color, Uint8 * touched); + SDL_Texture * texture, SDL_Renderer * renderer, int x, int y, int y_outside); +void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, Uint32 draw_color, Uint8 * touched); void init_queue(void); void add_to_queue(int x, int y, int y_outside); @@ -140,9 +136,8 @@ void add_to_queue(int x, int y, int y_outside) if (queue_end + 1 > queue_size) { queue_t *tmp; - tmp = - (queue_t *) realloc(queue, - sizeof(queue_t) * (queue_size + QUEUE_SIZE_CHUNK)); + + tmp = (queue_t *) realloc(queue, sizeof(queue_t) * (queue_size + QUEUE_SIZE_CHUNK)); if (tmp == NULL) { fprintf(stderr, "Fill queue cannot be realloc()'d\n"); @@ -256,25 +251,22 @@ int would_flood_fill(SDL_Surface * canvas, Uint32 cur_colr, Uint32 old_colr) void do_flood_fill(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, - Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, - Uint8 * touched) + Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, Uint8 * touched) { - simulate_flood_fill(screen, texture, renderer, last, canvas, x, y, cur_colr, - old_colr, x1, y1, x2, y2, touched); + simulate_flood_fill(screen, texture, renderer, last, canvas, x, y, cur_colr, old_colr, x1, y1, x2, y2, touched); } -Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, - double pct) +Uint32 blend(SDL_Surface * canvas, Uint32 draw_colr, Uint32 old_colr, double pct) { Uint8 old_r, old_g, old_b, draw_r, draw_g, draw_b, new_r, new_g, new_b; SDL_GetRGB(draw_colr, canvas->format, &draw_r, &draw_g, &draw_b); SDL_GetRGB(old_colr, canvas->format, &old_r, &old_g, &old_b); - new_r = (Uint8) (((float) old_r) * (1.00 - pct) + ((float) draw_r * pct)); - new_g = (Uint8) (((float) old_g) * (1.00 - pct) + ((float) draw_g * pct)); - new_b = (Uint8) (((float) old_b) * (1.00 - pct) + ((float) draw_b * pct)); + new_r = (Uint8) (((float)old_r) * (1.00 - pct) + ((float)draw_r * pct)); + new_g = (Uint8) (((float)old_g) * (1.00 - pct) + ((float)draw_g * pct)); + new_b = (Uint8) (((float)old_b) * (1.00 - pct) + ((float)draw_b * pct)); return SDL_MapRGB(canvas->format, draw_r, draw_g, draw_b); return SDL_MapRGB(canvas->format, new_r, new_g, new_b); @@ -308,8 +300,7 @@ void simulate_flood_fill(SDL_Surface * screen, SDL_Texture * texture, /* Do the work (possibly queuing more, as we go) */ while (remove_from_queue(&x, &y, &y_outside)) { - simulate_flood_fill_outside_check(screen, texture, renderer, x, y, - y_outside); + simulate_flood_fill_outside_check(screen, texture, renderer, x, y, y_outside); } cleanup_queue(); @@ -320,9 +311,7 @@ void simulate_flood_fill(SDL_Surface * screen, SDL_Texture * texture, } void simulate_flood_fill_outside_check(SDL_Surface * screen, - SDL_Texture * texture, - SDL_Renderer * renderer, int x, int y, - int y_outside) + SDL_Texture * texture, SDL_Renderer * renderer, int x, int y, int y_outside) { int fillL, fillR, narrowFillL, narrowFillR, i, outside, just_queued; double in_line, closeness; @@ -374,9 +363,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, /* Find left side, filling along the way */ - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, - fillL /* - 1 */ , y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillL /* - 1 */ , y); in_line = colors_close(global_canvas, px_colr, global_old_colr); outside = 0; while (in_line < COLOR_MATCH_WIDE && outside < WIDE_MATCH_THRESHOLD) @@ -399,17 +386,12 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, global_touched[(y * global_canvas->w) + fillL] = touch_byt; } - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); putpixels[global_canvas->format->BytesPerPixel] (global_canvas, fillL, y, - blend(global_canvas, - global_cur_colr, - px_colr, - (1.0 - in_line))); + blend(global_canvas, global_cur_colr, px_colr, (1.0 - in_line))); fillL--; - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); if (fillL >= 0) { @@ -432,13 +414,9 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, global_touched[(y * global_canvas->w) + fillL] = touch_byt; } - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillL, y); putpixels[global_canvas->format->BytesPerPixel] (global_canvas, fillL, y, - blend(global_canvas, - global_cur_colr, - px_colr, - (1.0 - in_line))); + blend(global_canvas, global_cur_colr, px_colr, (1.0 - in_line))); } @@ -452,8 +430,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, /* Find right side, filling along the way */ - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillR + 1, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillR + 1, y); in_line = colors_close(global_canvas, px_colr, global_old_colr); outside = 0; while (in_line < COLOR_MATCH_WIDE && outside < WIDE_MATCH_THRESHOLD) @@ -476,17 +453,12 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, global_touched[(y * global_canvas->w) + fillR] = touch_byt; } - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); putpixels[global_canvas->format->BytesPerPixel] (global_canvas, fillR, y, - blend(global_canvas, - global_cur_colr, - px_colr, - (1.0 - in_line))); + blend(global_canvas, global_cur_colr, px_colr, (1.0 - in_line))); fillR++; - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); if (fillR < global_canvas->w) { @@ -509,13 +481,9 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, global_touched[(y * global_canvas->w) + fillR] = touch_byt; } - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, fillR, y); putpixels[global_canvas->format->BytesPerPixel] (global_canvas, fillR, y, - blend(global_canvas, - global_cur_colr, - px_colr, - (1.0 - in_line))); + blend(global_canvas, global_cur_colr, px_colr, (1.0 - in_line))); } if (fillR > global_extent_x2) @@ -533,15 +501,11 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, { for (i = narrowFillL; i <= narrowFillR; i++) { - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, i, y - 1); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, i, y - 1); closeness = colors_close(global_canvas, px_colr, global_old_colr); - if (closeness < COLOR_MATCH_NARROW || - (closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)) + if (closeness < COLOR_MATCH_NARROW || (closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)) { - if (!just_queued - && (global_touched == NULL - || !global_touched[((y - 1) * global_canvas->w) + i])) + if (!just_queued && (global_touched == NULL || !global_touched[((y - 1) * global_canvas->w) + i])) { add_to_queue(i, y - 1, y_outside + 1); just_queued = 1; @@ -566,15 +530,11 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, { for (i = narrowFillL; i <= narrowFillR; i++) { - px_colr = - getpixels[global_last->format->BytesPerPixel] (global_last, i, y + 1); + px_colr = getpixels[global_last->format->BytesPerPixel] (global_last, i, y + 1); closeness = colors_close(global_canvas, px_colr, global_old_colr); - if (closeness < COLOR_MATCH_NARROW || - (closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)) + if (closeness < COLOR_MATCH_NARROW || (closeness < COLOR_MATCH_WIDE && y_outside < WIDE_MATCH_THRESHOLD)) { - if (!just_queued - && (global_touched == NULL - || !global_touched[((y + 1) * global_canvas->w) + i])) + if (!just_queued && (global_touched == NULL || !global_touched[((y + 1) * global_canvas->w) + i])) { add_to_queue(i, y + 1, y_outside + 1); just_queued = 1; @@ -595,8 +555,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, void draw_linear_gradient(SDL_Surface * canvas, SDL_Surface * last, int x_left, int y_top, int x_right, int y_bottom, - int x1, int y1, int x2, int y2, Uint32 draw_color, - Uint8 * touched) + int x1, int y1, int x2, int y2, Uint32 draw_color, Uint8 * touched) { Uint32 old_colr, new_colr; int xx, yy; @@ -643,17 +602,11 @@ void draw_linear_gradient(SDL_Surface * canvas, SDL_Surface * last, } /* Apply fuzziness at any antialiased edges we detected */ - ratio = (ratio * ((float) touched[yy * canvas->w + xx] / 255.0)); + ratio = (ratio * ((float)touched[yy * canvas->w + xx] / 255.0)); - new_r = - (Uint8) (((float) old_r) * ratio + - ((float) draw_r * (1.0 - ratio))); - new_g = - (Uint8) (((float) old_g) * ratio + - ((float) draw_g * (1.0 - ratio))); - new_b = - (Uint8) (((float) old_b) * ratio + - ((float) draw_b * (1.0 - ratio))); + new_r = (Uint8) (((float)old_r) * ratio + ((float)draw_r * (1.0 - ratio))); + new_g = (Uint8) (((float)old_g) * ratio + ((float)draw_g * (1.0 - ratio))); + new_b = (Uint8) (((float)old_b) * ratio + ((float)draw_b * (1.0 - ratio))); new_colr = SDL_MapRGB(canvas->format, new_r, new_g, new_b); putpixels[canvas->format->BytesPerPixel] (canvas, xx, yy, new_colr); @@ -662,8 +615,7 @@ void draw_linear_gradient(SDL_Surface * canvas, SDL_Surface * last, } } -void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, - Uint32 draw_color, Uint8 * touched) +void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, Uint32 draw_color, Uint8 * touched) { int xx, yy; int pix; @@ -675,13 +627,12 @@ void draw_brush_fill_single(SDL_Surface * canvas, int x, int y, pix = ((y + yy) * canvas->w) + (x + xx); if (pix >= 0 && pix < canvas->w * canvas->h) + { + if ((xx * xx) + (yy * yy) < (16 * 16) && touched[pix]) { - if ((xx * xx) + (yy * yy) < (16 * 16) && touched[pix]) - { - putpixels[canvas->format->BytesPerPixel] (canvas, x + xx, y + yy, - draw_color); - } + putpixels[canvas->format->BytesPerPixel] (canvas, x + xx, y + yy, draw_color); } + } } } } @@ -690,8 +641,7 @@ void draw_brush_fill(SDL_Surface * canvas, int x_left ATTRIBUTE_UNUSED, int y_top ATTRIBUTE_UNUSED, int x_right ATTRIBUTE_UNUSED, int y_bottom ATTRIBUTE_UNUSED, int x1, int y1, int x2, - int y2, Uint32 draw_color, Uint8 * touched, int *up_x1, - int *up_y1, int *up_x2, int *up_y2) + int y2, Uint32 draw_color, Uint8 * touched, int *up_x1, int *up_y1, int *up_x2, int *up_y2) { int dx, dy; int y; @@ -709,7 +659,7 @@ void draw_brush_fill(SDL_Surface * canvas, if (dx != 0) { - m = ((float) dy) / ((float) dx); + m = ((float)dy) / ((float)dx); b = y1 - m * x1; if (x2 >= x1) @@ -770,8 +720,7 @@ void draw_brush_fill(SDL_Surface * canvas, } void draw_radial_gradient(SDL_Surface * canvas, int x_left, int y_top, - int x_right, int y_bottom, int x, int y, - Uint32 draw_color, Uint8 * touched) + int x_right, int y_bottom, int x, int y, Uint32 draw_color, Uint8 * touched) { Uint32 old_colr, new_colr; int xx, yy; @@ -800,40 +749,33 @@ void draw_radial_gradient(SDL_Surface * canvas, int x_left, int y_top, pix = (yy * canvas->w) + xx; if (pix >= 0 && pix < canvas->w * canvas->h) + { + if (touched[pix]) { - if (touched[pix]) + /* Determine the distance from the click point */ + xd = fabs((float)(xx - x)); + yd = fabs((float)(yy - y)); + dist = sqrt(xd * xd + yd * yd); + if (dist < rad) { - /* Determine the distance from the click point */ - xd = fabs((float) (xx - x)); - yd = fabs((float) (yy - y)); - dist = sqrt(xd * xd + yd * yd); - if (dist < rad) - { - ratio = (dist / rad); + ratio = (dist / rad); - /* Get the old color, and blend it (with a distance-based ratio) with the target color */ - old_colr = - getpixels[canvas->format->BytesPerPixel] (canvas, xx, yy); - SDL_GetRGB(old_colr, canvas->format, &old_r, &old_g, &old_b); + /* Get the old color, and blend it (with a distance-based ratio) with the target color */ + old_colr = getpixels[canvas->format->BytesPerPixel] (canvas, xx, yy); + SDL_GetRGB(old_colr, canvas->format, &old_r, &old_g, &old_b); - /* Apply fuzziness at any antialiased edges we detected */ - ratio = (ratio * ((float) touched[pix] / 255.0)); + /* Apply fuzziness at any antialiased edges we detected */ + ratio = (ratio * ((float)touched[pix] / 255.0)); - new_r = - (Uint8) (((float) old_r) * ratio + - ((float) draw_r * (1.00 - ratio))); - new_g = - (Uint8) (((float) old_g) * ratio + - ((float) draw_g * (1.00 - ratio))); - new_b = - (Uint8) (((float) old_b) * ratio + - ((float) draw_b * (1.00 - ratio))); + new_r = (Uint8) (((float)old_r) * ratio + ((float)draw_r * (1.00 - ratio))); + new_g = (Uint8) (((float)old_g) * ratio + ((float)draw_g * (1.00 - ratio))); + new_b = (Uint8) (((float)old_b) * ratio + ((float)draw_b * (1.00 - ratio))); - new_colr = SDL_MapRGB(canvas->format, new_r, new_g, new_b); - putpixels[canvas->format->BytesPerPixel] (canvas, xx, yy, new_colr); - } + new_colr = SDL_MapRGB(canvas->format, new_r, new_g, new_b); + putpixels[canvas->format->BytesPerPixel] (canvas, xx, yy, new_colr); } } + } } } } @@ -845,9 +787,12 @@ void draw_radial_gradient(SDL_Surface * canvas, int x_left, int y_top, void sdf_pt_get(sdf_grid * g, int x, int y, sdf_point * p) { - if (x >= 0 && x < g->w && y >= 0 && y < g->h) { + if (x >= 0 && x < g->w && y >= 0 && y < g->h) + { memcpy(p, &(g->grid[y][x]), sizeof(sdf_point)); - } else { + } + else + { memcpy(p, &(sdf_pt_empty), sizeof(sdf_point)); } } @@ -870,37 +815,44 @@ void sdf_compare(sdf_grid * g, sdf_point * p, int x, int y, int offsetx, int off other.dx += offsetx; other.dy += offsety; - if (sdf_distsq(other) < sdf_distsq(*p)) { + if (sdf_distsq(other) < sdf_distsq(*p)) + { p->dx = other.dx; p->dy = other.dy; } } -int malloc_sdf_grid(sdf_grid * g, int w, int h) { +int malloc_sdf_grid(sdf_grid * g, int w, int h) +{ int i, abort; g->w = w; g->h = h; - g->grid = (sdf_point * *) malloc(h * sizeof(sdf_point *)); - if (g->grid == NULL) { + g->grid = (sdf_point * *)malloc(h * sizeof(sdf_point *)); + if (g->grid == NULL) + { fprintf(stderr, "malloc_sdf_grid() cannot malloc() g->grid!\n"); free(g); return 0; } - for (i = 0; i < h; i++) { + for (i = 0; i < h; i++) + { g->grid[i] = NULL; } abort = 0; - for (i = 0; i < h && !abort; i++) { + for (i = 0; i < h && !abort; i++) + { g->grid[i] = (sdf_point *) malloc(w * sizeof(sdf_point)); - if (g->grid[i] == NULL) { + if (g->grid[i] == NULL) + { abort = 1; } } - if (abort) { + if (abort) + { fprintf(stderr, "malloc_sdf_grid() cannot malloc() g->grid[]!\n"); free_sdf_grid(g); return 0; @@ -909,11 +861,14 @@ int malloc_sdf_grid(sdf_grid * g, int w, int h) { return 1; } -void free_sdf_grid(sdf_grid * g) { +void free_sdf_grid(sdf_grid * g) +{ int i; - for (i = 0; i < g->h; i++) { - if (g->grid[i] != NULL) { + for (i = 0; i < g->h; i++) + { + if (g->grid[i] != NULL) + { free(g->grid[i]); } } @@ -921,15 +876,21 @@ void free_sdf_grid(sdf_grid * g) { } -void sdf_fill_bitmask_to_sdf_grids(Uint8 * bitmask, int w, int h, sdf_grid * g1, sdf_grid * g2) { +void sdf_fill_bitmask_to_sdf_grids(Uint8 * bitmask, int w, int h, sdf_grid * g1, sdf_grid * g2) +{ int x, y; - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - if (bitmask[y * w + x]) { + for (y = 0; y < h; y++) + { + for (x = 0; x < w; x++) + { + if (bitmask[y * w + x]) + { sdf_pt_put(g1, x, y, sdf_pt_inside); sdf_pt_put(g2, x, y, sdf_pt_empty); - } else { + } + else + { sdf_pt_put(g1, x, y, sdf_pt_empty); sdf_pt_put(g2, x, y, sdf_pt_inside); } @@ -938,40 +899,47 @@ void sdf_fill_bitmask_to_sdf_grids(Uint8 * bitmask, int w, int h, sdf_grid * g1, } -void sdf_generate(sdf_grid * g) { +void sdf_generate(sdf_grid * g) +{ int x, y; sdf_point p; /* Pass 0 */ - for (y = 0; y < g->h; y++) { - for (x = 0; x < g->w; x++) { + for (y = 0; y < g->h; y++) + { + for (x = 0; x < g->w; x++) + { sdf_pt_get(g, x, y, &p); - sdf_compare(g, &p, x, y, -1, 0); - sdf_compare(g, &p, x, y, 0, -1); + sdf_compare(g, &p, x, y, -1, 0); + sdf_compare(g, &p, x, y, 0, -1); sdf_compare(g, &p, x, y, -1, -1); - sdf_compare(g, &p, x, y, 1, -1); + sdf_compare(g, &p, x, y, 1, -1); sdf_pt_put(g, x, y, p); } - for (x = g->w - 1; x >= 0; x--) { + for (x = g->w - 1; x >= 0; x--) + { sdf_pt_get(g, x, y, &p); - sdf_compare(g, &p, x, y, 1, 0); + sdf_compare(g, &p, x, y, 1, 0); sdf_pt_put(g, x, y, p); } } /* Pass 1 */ - for (y = g->h - 1; y >= 0; y--) { - for (x = g->w - 1; x >= 0; x--) { + for (y = g->h - 1; y >= 0; y--) + { + for (x = g->w - 1; x >= 0; x--) + { sdf_pt_get(g, x, y, &p); - sdf_compare(g, &p, x, y, 1, 0); - sdf_compare(g, &p, x, y, 0, 1); + sdf_compare(g, &p, x, y, 1, 0); + sdf_compare(g, &p, x, y, 0, 1); sdf_compare(g, &p, x, y, -1, 1); - sdf_compare(g, &p, x, y, 1, 1); + sdf_compare(g, &p, x, y, 1, 1); sdf_pt_put(g, x, y, p); } - for (x = 0; x < g->w; x++) { + for (x = 0; x < g->w; x++) + { sdf_pt_get(g, x, y, &p); sdf_compare(g, &p, x, y, -1, 0); sdf_pt_put(g, x, y, p); @@ -989,21 +957,24 @@ void draw_shaped_gradient(SDL_Surface * canvas, Uint32 draw_color, Uint8 * touch int pix_idx; float ratio; Uint8 draw_r, draw_g, draw_b, old_r, old_g, old_b, new_r, new_g, new_b; - Uint8 * bitmask; + Uint8 *bitmask; sdf_grid g1, g2; /* Create space for bitmask (based on `touched`) and SDF output large enough for the area being filled */ bitmask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h); - if (bitmask == NULL) { + if (bitmask == NULL) + { return; } - if (!malloc_sdf_grid(&g1, canvas->w, canvas->h)) { + if (!malloc_sdf_grid(&g1, canvas->w, canvas->h)) + { free(bitmask); return; } - if (!malloc_sdf_grid(&g2, canvas->w, canvas->h)) { + if (!malloc_sdf_grid(&g2, canvas->w, canvas->h)) + { free(bitmask); free_sdf_grid(&g1); return; @@ -1011,8 +982,10 @@ void draw_shaped_gradient(SDL_Surface * canvas, Uint32 draw_color, Uint8 * touch /* Convert the `touched` values into a bitmask to feed into the SDF routines */ - for (yy = 0; yy < canvas->h; yy++) { - for (xx = 0; xx < canvas->w; xx++) { + for (yy = 0; yy < canvas->h; yy++) + { + for (xx = 0; xx < canvas->w; xx++) + { /* Converting 0-255 to 0/1 */ bitmask[yy * canvas->w + xx] = (touched[(yy * canvas->w) + xx] >= 128); } @@ -1036,49 +1009,42 @@ void draw_shaped_gradient(SDL_Surface * canvas, Uint32 draw_color, Uint8 * touch pix_idx = (yy * canvas->w) + xx; if (pix_idx >= 0 && pix_idx < canvas->w * canvas->h) + { + if (touched[pix_idx]) { - if (touched[pix_idx]) - { - sdf_point p; - double dist1, dist2, dist; + sdf_point p; + double dist1, dist2, dist; - sdf_pt_get(&g1, xx, yy, &p); - dist1 = sqrt(sdf_distsq(p)); + sdf_pt_get(&g1, xx, yy, &p); + dist1 = sqrt(sdf_distsq(p)); - sdf_pt_get(&g2, xx, yy, &p); - dist2 = sqrt(sdf_distsq(p)); + sdf_pt_get(&g2, xx, yy, &p); + dist2 = sqrt(sdf_distsq(p)); - dist = dist1 - dist2; + dist = dist1 - dist2; - /* Determine the distance from the click point */ - ratio = ((float) ((dist * 10) + 255)) / 255.0; // Magic numbers :-( -bjk 2023.02.25 - if (ratio < 0.0) - ratio = 0.0; - else if (ratio > 1.0) - ratio = 1.0; + /* Determine the distance from the click point */ + ratio = ((float)((dist * 10) + 255)) / 255.0; // Magic numbers :-( -bjk 2023.02.25 + if (ratio < 0.0) + ratio = 0.0; + else if (ratio > 1.0) + ratio = 1.0; - /* Get the old color, and blend it (with a distance-based ratio) with the target color */ - old_colr = - getpixels[canvas->format->BytesPerPixel] (canvas, xx, yy); - SDL_GetRGB(old_colr, canvas->format, &old_r, &old_g, &old_b); + /* Get the old color, and blend it (with a distance-based ratio) with the target color */ + old_colr = getpixels[canvas->format->BytesPerPixel] (canvas, xx, yy); + SDL_GetRGB(old_colr, canvas->format, &old_r, &old_g, &old_b); - /* Apply fuzziness at any antialiased edges we detected */ - ratio = (ratio * ((float) touched[pix_idx] / 255.0)); + /* Apply fuzziness at any antialiased edges we detected */ + ratio = (ratio * ((float)touched[pix_idx] / 255.0)); - new_r = - (Uint8) (((float) old_r) * ratio + - ((float) draw_r * (1.00 - ratio))); - new_g = - (Uint8) (((float) old_g) * ratio + - ((float) draw_g * (1.00 - ratio))); - new_b = - (Uint8) (((float) old_b) * ratio + - ((float) draw_b * (1.00 - ratio))); + new_r = (Uint8) (((float)old_r) * ratio + ((float)draw_r * (1.00 - ratio))); + new_g = (Uint8) (((float)old_g) * ratio + ((float)draw_g * (1.00 - ratio))); + new_b = (Uint8) (((float)old_b) * ratio + ((float)draw_b * (1.00 - ratio))); - new_colr = SDL_MapRGB(canvas->format, new_r, new_g, new_b); - putpixels[canvas->format->BytesPerPixel] (canvas, xx, yy, new_colr); - } + new_colr = SDL_MapRGB(canvas->format, new_r, new_g, new_b); + putpixels[canvas->format->BytesPerPixel] (canvas, xx, yy, new_colr); } + } } } diff --git a/src/fill.h b/src/fill.h index 756ad4ebc..aa38a3da4 100644 --- a/src/fill.h +++ b/src/fill.h @@ -40,24 +40,19 @@ int would_flood_fill(SDL_Surface * canvas, Uint32 cur_colr, Uint32 old_colr); void do_flood_fill(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, - Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, - Uint8 * touched); + Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, Uint8 * touched); void simulate_flood_fill(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, SDL_Surface * last, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, - Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, - Uint8 * touched); + Uint32 old_colr, int *x1, int *y1, int *x2, int *y2, Uint8 * touched); void draw_linear_gradient(SDL_Surface * canvas, SDL_Surface * last, int x_left, int y_top, int x_right, int y_bottom, - int x1, int y1, int x2, int y2, Uint32 draw_color, - Uint8 * touched); + int x1, int y1, int x2, int y2, Uint32 draw_color, Uint8 * touched); void draw_radial_gradient(SDL_Surface * canvas, int x_left, int y_top, - int x_right, int y_bottom, int x, int y, - Uint32 draw_color, Uint8 * touched); + int x_right, int y_bottom, int x, int y, Uint32 draw_color, Uint8 * touched); void draw_shaped_gradient(SDL_Surface * canvas, Uint32 draw_color, Uint8 * touched); void draw_brush_fill(SDL_Surface * canvas, int x_left, int y_top, int x_right, int y_bottom, int x1, int y1, int x2, int y2, - Uint32 draw_color, Uint8 * touched, int *up_x1, - int *up_y1, int *up_x2, int *up_y2); + Uint32 draw_color, Uint8 * touched, int *up_x1, int *up_y1, int *up_x2, int *up_y2); #endif diff --git a/src/fill_tools.h b/src/fill_tools.h index d76df1fe2..73efbf4e9 100644 --- a/src/fill_tools.h +++ b/src/fill_tools.h @@ -59,12 +59,9 @@ const char *const fill_names[NUM_FILLS] = { const char *const fill_tips[NUM_FILLS] = { gettext_noop("Click to fill an area with a solid color."), gettext_noop("Click and drag to fill an area by hand, using a brush."), - gettext_noop - ("Click and drag to fill an area with a linear gradient (from the chosen color to transparent)."), - gettext_noop - ("Click to fill an area with a radial gradient (from the chosen color to transparent)."), - gettext_noop - ("Click to fill an area with a shaped gradient (from the chosen color to transparent).") + gettext_noop("Click and drag to fill an area with a linear gradient (from the chosen color to transparent)."), + gettext_noop("Click to fill an area with a radial gradient (from the chosen color to transparent)."), + gettext_noop("Click to fill an area with a shaped gradient (from the chosen color to transparent).") }; const char *const fill_img_fnames[NUM_FILLS] = { diff --git a/src/fonts.c b/src/fonts.c index 04cf03b03..a9b60b6a2 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -142,6 +142,7 @@ int all_locale_fonts; volatile long font_thread_done; volatile long font_thread_aborted; volatile long waiting_for_fonts; + #ifdef FORKED_FONTS static int font_scanner_pid; #endif @@ -180,8 +181,7 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size) { char str[128]; - snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, - lang_prefix); + snprintf(str, sizeof(str), "%sfonts/locale/%s.ttf", DATA_PREFIX, lang_prefix); ret = TuxPaint_Font_OpenFont("", str, size); @@ -214,16 +214,14 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size) void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) { #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_CloseFont step 1 (%p)\n", __FILE__, __LINE__, - tpf); + printf("%s:%d - TuxPaint_Font_CloseFont step 1 (%p)\n", __FILE__, __LINE__, tpf); #endif if (!tpf) return; #ifndef NO_SDLPANGO #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_CloseFont step 2 (%p, %d)\n", __FILE__, - __LINE__, tpf->pango_context, tpf->typ); + printf("%s:%d - TuxPaint_Font_CloseFont step 2 (%p, %d)\n", __FILE__, __LINE__, tpf->pango_context, tpf->typ); #endif if (tpf->typ == FONT_TYPE_PANGO) if (tpf->pango_context) @@ -236,8 +234,7 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) #endif #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_CloseFont step 3 (%p, %d)\n", __FILE__, - __LINE__, tpf->ttf_font, tpf->typ); + printf("%s:%d - TuxPaint_Font_CloseFont step 3 (%p, %d)\n", __FILE__, __LINE__, tpf->ttf_font, tpf->typ); fflush(stdout); #endif if (tpf->typ == FONT_TYPE_TTF) @@ -256,8 +253,7 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) free(tpf); } -TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, - const char *ttffilename, int size) +TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffilename, int size) { TTF_Font *ttf_font; TuxPaint_Font *tpf = NULL; @@ -269,8 +265,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, #endif #ifdef DEBUG - printf("%s:%d - OpenFont(pango:\"%s\", ttf:\"%s\")\n", __FILE__, __LINE__, - pangodesc, ttffilename); + printf("%s:%d - OpenFont(pango:\"%s\", ttf:\"%s\")\n", __FILE__, __LINE__, pangodesc, ttffilename); #endif #ifndef NO_SDLPANGO @@ -282,16 +277,15 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, tpf->desc = strdup(desc); #ifdef DEBUG - printf("%s:%d - Creating Pango context: \"%s\"\n", __FILE__, __LINE__, - desc); + printf("%s:%d - Creating Pango context: \"%s\"\n", __FILE__, __LINE__, desc); #endif #ifdef __APPLE__ /* - * SDLPango_CreateContext_GivenFontDesc() defaults to ASCII character set - * (at least on the macOS) unless the CHARSET environment varaible is set. - * May also want to set on non-macOS platforms, also. - */ + * SDLPango_CreateContext_GivenFontDesc() defaults to ASCII character set + * (at least on the macOS) unless the CHARSET environment varaible is set. + * May also want to set on non-macOS platforms, also. + */ mysetenv("CHARSET", "UTF-8"); #endif @@ -325,8 +319,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, if (ttffilename != NULL && ttffilename[0] != '\0') { #ifdef DEBUG - printf("%s:%d - Considering loading TTF \"%s\"\n", __FILE__, __LINE__, - ttffilename); + printf("%s:%d - Considering loading TTF \"%s\"\n", __FILE__, __LINE__, ttffilename); fflush(stdout); #endif @@ -336,8 +329,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, if (!strcmp(ttffilename, problemFonts[i++])) { #ifdef DEBUG - fprintf(stderr, "Notice: Skipping problematic font: \"%s\"\n", - ttffilename); + fprintf(stderr, "Notice: Skipping problematic font: \"%s\"\n", ttffilename); #endif return NULL; /* bail on known problematic fonts that cause TTF_OpenFont to crash */ } @@ -349,9 +341,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, if (strstr(ttffilename, problemFontExtensions[i++])) { #ifdef DEBUG - fprintf(stderr, - "Notice: Skipping font with problematic extension: \"%s\"\n", - ttffilename); + fprintf(stderr, "Notice: Skipping font with problematic extension: \"%s\"\n", ttffilename); #endif return NULL; /* bail on known problematic font types that cause TTF_OpenFont to crash */ } @@ -361,13 +351,12 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, if (ttf_font == NULL) { - fprintf(stderr, "Cannot open TTF font '%s' (size %d)\n", ttffilename, - size); + fprintf(stderr, "Cannot open TTF font '%s' (size %d)\n", ttffilename, size); return NULL; } familyname = TTF_FontFaceFamilyName(ttf_font); /* N.B.: I don't believe we're supposed to free() this... -bjk 2021.10.26 */ - (void) familyname; // avoid compiler complaints if NO_SDLPANGO is set, or ALWAYS_LOAD_FONT_WITH_PANGO is not set, and DEBUG is not set + (void)familyname; // avoid compiler complaints if NO_SDLPANGO is set, or ALWAYS_LOAD_FONT_WITH_PANGO is not set, and DEBUG is not set #ifdef DEBUG printf("%s:%d - Loaded %s (\"%s\")\n", __FILE__, __LINE__, ttffilename, @@ -406,8 +395,7 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, tpf->desc = strdup(ttffilename); #ifdef DEBUG - printf("%s:%d - Succeeded loading %s via SDL_ttf\n", __FILE__, __LINE__, - ttffilename); + printf("%s:%d - Succeeded loading %s via SDL_ttf\n", __FILE__, __LINE__, ttffilename); #endif tpf->height = TTF_FontHeight(tpf->ttf_font); @@ -614,9 +602,7 @@ static void groupfonts_range(style_info ** base, int count) if (num_font_families == num_font_families_max) { num_font_families_max = num_font_families_max * 5 / 4 + 30; - user_font_families = - realloc(user_font_families, - num_font_families_max * sizeof *user_font_families); + user_font_families = realloc(user_font_families, num_font_families_max * sizeof *user_font_families); } fi = calloc(1, sizeof *fi); @@ -633,8 +619,7 @@ static void groupfonts_range(style_info ** base, int count) { #if 0 // THREADED_FONTS - printf("too many boldness levels, discarding: %s, %s\n", - base[i]->family, base[i]->style); + printf("too many boldness levels, discarding: %s, %s\n", base[i]->family, base[i]->style); #endif continue; } @@ -644,11 +629,9 @@ static void groupfonts_range(style_info ** base, int count) { #if 0 // THREADED_FONTS - printf("duplicates, discarding: %s, %s\n", base[i]->family, - base[i]->style); + printf("duplicates, discarding: %s, %s\n", base[i]->family, base[i]->style); printf("b %d, spot %d\n", b, spot); - printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], - fi->filename[2], fi->filename[3]); + printf("occupancy %p %p %p %p\n", fi->filename[0], fi->filename[1], fi->filename[2], fi->filename[3]); #endif continue; } @@ -872,8 +855,7 @@ static void parse_font_style(style_info * si) si->boldness = 1; // we'll count both TrueType and OpenType - si->truetype = !!strcasestr(si->filename, ".ttf") - || !!strcasestr(si->filename, ".otf"); + si->truetype = !!strcasestr(si->filename, ".ttf") || !!strcasestr(si->filename, ".otf"); } @@ -911,8 +893,7 @@ static void groupfonts(void) while (i--) parse_font_style(user_font_styles[i]); - qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], - compar_fontgroup); + qsort(user_font_styles, num_font_styles, sizeof user_font_styles[0], compar_fontgroup); //printf("groupfonts() qsort(user_font_styles...)\n"); //fflush(stdout); @@ -945,8 +926,7 @@ static void groupfonts(void) free(user_font_styles); user_font_styles = NULL; // just to catch bugs - qsort(user_font_families, num_font_families, sizeof user_font_families[0], - compar_fontkiller); + qsort(user_font_families, num_font_families, sizeof user_font_families[0], compar_fontkiller); low = 0; for (;;) { @@ -958,15 +938,13 @@ static void groupfonts(void) { if (++high >= num_font_families) break; - if (strcmp - (user_font_families[low]->family, user_font_families[high]->family)) + if (strcmp(user_font_families[low]->family, user_font_families[high]->family)) break; } dupe_markdown_range(user_font_families + low, high - low); low = high; } - qsort(user_font_families, num_font_families, sizeof user_font_families[0], - compar_fontscore); + qsort(user_font_families, num_font_families, sizeof user_font_families[0], compar_fontscore); //printf("groupfonts() qsort(user_font_families 2...)\n"); //fflush(stdout); if (num_font_families > 0 && user_font_families[0]->score < 0) @@ -975,8 +953,7 @@ static void groupfonts(void) // THREADED_FONTS printf("Trim starting with %d families\n", num_font_families); #endif - while (num_font_families > 1 - && user_font_families[num_font_families - 1]->score < 0) + while (num_font_families > 1 && user_font_families[num_font_families - 1]->score < 0) { i = --num_font_families; free(user_font_families[i]->directory); @@ -1002,9 +979,7 @@ static void groupfonts(void) static void loadfonts_locale_filter(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, - const char *const dir, - const char *restrict const locale) + SDL_Renderer * renderer, const char *const dir, const char *restrict const locale) { char buf[TP_FTW_PATHSIZE]; unsigned dirlen = strlen(dir); @@ -1012,27 +987,23 @@ static void loadfonts_locale_filter(SDL_Surface * screen, DEBUG_PRINTF("Loading fonts from [%s]\n", dir); memcpy(buf, dir, dirlen); - tp_ftw(screen, texture, renderer, buf, dirlen, 1, loadfont_callback, - locale); + tp_ftw(screen, texture, renderer, buf, dirlen, 1, loadfont_callback, locale); } -static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, const char *const dir) +static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer, const char *const dir) { loadfonts_locale_filter(screen, texture, renderer, dir, NULL); } /* static */ int load_user_fonts(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, void *vp, - const char *restrict const locale) + SDL_Renderer * renderer, void *vp, const char *restrict const locale) { char *homedirdir; - (void) vp; // junk passed by threading library + (void)vp; // junk passed by threading library - loadfonts_locale_filter(screen, texture, renderer, DATA_PREFIX "fonts", - locale); + loadfonts_locale_filter(screen, texture, renderer, DATA_PREFIX "fonts", locale); if (!no_system_fonts) { @@ -1049,21 +1020,13 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; status_t result; - result = - find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, - sizeof(buffer)); + result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); loadfonts(screen, texture, renderer, buffer); - result = - find_directory(B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, volume, false, - buffer, sizeof(buffer)); + result = find_directory(B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); loadfonts(screen, texture, renderer, buffer); - result = - find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, - sizeof(buffer)); + result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); loadfonts(screen, texture, renderer, buffer); - result = - find_directory(B_USER_NONPACKAGED_FONTS_DIRECTORY, volume, false, - buffer, sizeof(buffer)); + result = find_directory(B_USER_NONPACKAGED_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); loadfonts(screen, texture, renderer, buffer); #elif defined(__APPLE__) loadfonts(screen, texture, renderer, "/System/Library/Fonts"); @@ -1102,8 +1065,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, #endif #ifdef __APPLE__ - homedirdir = - malloc(snprintf(NULL, 0, "%s/fonts", apple_globalPreferencesPath()) + 1); + homedirdir = malloc(snprintf(NULL, 0, "%s/fonts", apple_globalPreferencesPath()) + 1); if (homedirdir) { sprintf(homedirdir, "%s/fonts", apple_globalPreferencesPath()); @@ -1113,8 +1075,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, #endif #ifdef DEBUG - printf("%s:%d - Grouping %d fonts...\n", __FILE__, __LINE__, - num_font_styles); + printf("%s:%d - Grouping %d fonts...\n", __FILE__, __LINE__, num_font_styles); fflush(stdout); #endif @@ -1135,8 +1096,7 @@ static void loadfonts(SDL_Surface * screen, SDL_Texture * texture, #ifdef FORKED_FONTS void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, - const char *restrict const locale) + SDL_Renderer * renderer, const char *restrict const locale) { int sv[2]; int size, i; @@ -1202,8 +1162,7 @@ void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture, buf = malloc(size); walk = buf; #ifdef DEBUG - printf("%s:%d - Sending %u bytes with %u families.\n", __FILE__, __LINE__, - size, num_font_families); + printf("%s:%d - Sending %u bytes with %u families.\n", __FILE__, __LINE__, size, num_font_families); #endif *walk++ = num_font_families & 0xffu; *walk++ = num_font_families >> 8u; @@ -1272,8 +1231,7 @@ void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture, } -void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer) +void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer) { char *buf = NULL; unsigned buf_size = 0; @@ -1298,7 +1256,7 @@ void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, rc = read(font_socket_fd, buf + buf_fill, buf_size - buf_fill); #ifdef DEBUG printf("%s:%d - read: fd=%d buf_fill=%u buf_size=%u rc=%ld\n", __FILE__, - __LINE__, font_socket_fd, buf_fill, buf_size, (long int) rc); + __LINE__, font_socket_fd, buf_fill, buf_size, (long int)rc); #endif if (rc == -1) @@ -1339,11 +1297,10 @@ void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, show_progress_bar_(screen, texture, renderer); walk = buf; - num_font_families = *(unsigned char *) walk++; - num_font_families += *(unsigned char *) walk++ << 8u; + num_font_families = *(unsigned char *)walk++; + num_font_families += *(unsigned char *)walk++ << 8u; #ifdef DEBUG - printf("%s:%d - Got %u bytes with %u families.\n", __FILE__, __LINE__, - buf_fill, num_font_families); + printf("%s:%d - Got %u bytes with %u families.\n", __FILE__, __LINE__, buf_fill, num_font_families); #endif user_font_families = malloc(num_font_families * sizeof *user_font_families); @@ -1409,8 +1366,7 @@ TuxPaint_Font *getfonthandle(int desire) if (fi == NULL) { #ifdef DEBUG - printf("%s:%d - getfonthandle(%d) points to a NULL family\n", __FILE__, - __LINE__, desire); + printf("%s:%d - getfonthandle(%d) points to a NULL family\n", __FILE__, __LINE__, desire); fflush(stdout); #endif return NULL; @@ -1419,8 +1375,7 @@ TuxPaint_Font *getfonthandle(int desire) if (fi->filename != NULL) { #ifdef DEBUG - printf("%s:%d - Setting 'name' to fi->filename[%d (0x%x)]\n", __FILE__, - __LINE__, (int) text_state, (int) text_state); + printf("%s:%d - Setting 'name' to fi->filename[%d (0x%x)]\n", __FILE__, __LINE__, (int)text_state, (int)text_state); fflush(stdout); #endif @@ -1444,8 +1399,7 @@ TuxPaint_Font *getfonthandle(int desire) if (fi->handle) { #ifdef DEBUG - printf("%s:%d - fi->handle was set (0x%x)\n", __FILE__, __LINE__, - (int) (intptr_t) fi->handle); + printf("%s:%d - fi->handle was set (0x%x)\n", __FILE__, __LINE__, (int)(intptr_t) fi->handle); fflush(stdout); #endif @@ -1511,8 +1465,7 @@ TuxPaint_Font *getfonthandle(int desire) strcpy(description, ""); } - fi->handle = - TuxPaint_Font_OpenFont(description, pathname, text_sizes[text_size]); + fi->handle = TuxPaint_Font_OpenFont(description, pathname, text_sizes[text_size]); // if the font doesn't load, we die -- it did load OK before though if (fi->handle == NULL) @@ -1536,8 +1489,7 @@ TuxPaint_Font *getfonthandle(int desire) } #ifdef DEBUG - printf("%s:%d - calling TTF_SetFontStyle(0x%x)\n", __FILE__, __LINE__, - missing); + printf("%s:%d - calling TTF_SetFontStyle(0x%x)\n", __FILE__, __LINE__, missing); fflush(stdout); #endif @@ -1557,8 +1509,7 @@ TuxPaint_Font *getfonthandle(int desire) static int was_bad_font; // see if two font surfaces are the same -static int do_surfcmp(const SDL_Surface * const *const v1, - const SDL_Surface * const *const v2) +static int do_surfcmp(const SDL_Surface * const *const v1, const SDL_Surface * const *const v2) { const SDL_Surface *const s1 = *v1; const SDL_Surface *const s2 = *v2; @@ -1572,8 +1523,7 @@ static int do_surfcmp(const SDL_Surface * const *const v1, fprintf(stderr, "s1==s2?\n"); return 0; } - if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format - || !s2->format) + if (!s1 || !s2 || !s1->w || !s2->w || !s1->h || !s2->h || !s1->format || !s2->format) { /* One or the other or both SDL_Surfaces were invalid!? */ was_bad_font = 1; @@ -1596,11 +1546,12 @@ static int do_surfcmp(const SDL_Surface * const *const v1, /* Otherwise, compare the pixels in the surfaces (using `memcmp()`) */ { - const char *const c1 = (char *const) s1->pixels; - const char *const c2 = (char *const) s2->pixels; + const char *const c1 = (char *const)s1->pixels; + const char *const c2 = (char *const)s2->pixels; width = s1->format->BytesPerPixel * s1->w; - if (width == s1->pitch) { + if (width == s1->pitch) + { /* Same width, just compare scanline */ return memcmp(c1, c2, width * s1->h); } @@ -1625,7 +1576,8 @@ static int surfcmp(const void *s1, const void *s2) { int diff = do_surfcmp(s1, s2); - if (!diff) { + if (!diff) + { #ifdef DEBUG printf("surfcmp found two identical renders!\n"); #endif @@ -1708,8 +1660,7 @@ int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf) if (tpf == NULL) { #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_FontHeight() received NULL\n", __FILE__, - __LINE__); + printf("%s:%d - TuxPaint_Font_FontHeight() received NULL\n", __FILE__, __LINE__); fflush(stdout); #endif return (1); @@ -1723,8 +1674,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf) if (tpf == NULL) { #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() received NULL\n", - __FILE__, __LINE__); + printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() received NULL\n", __FILE__, __LINE__); fflush(stdout); #endif return (""); @@ -1733,7 +1683,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf) #ifndef NO_SDLPANGO if (tpf->typ == FONT_TYPE_PANGO) { - (void) (tpf); + (void)(tpf); /* FIXME */ return (""); @@ -1744,8 +1694,7 @@ const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf) return (TTF_FontFaceFamilyName(tpf->ttf_font)); #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() is confused\n", __FILE__, - __LINE__); + printf("%s:%d - TuxPaint_Font_FontFaceFamilyName() is confused\n", __FILE__, __LINE__); #endif return (""); @@ -1756,8 +1705,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) if (tpf == NULL) { #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_FontFaceStyleName() received NULL\n", - __FILE__, __LINE__); + printf("%s:%d - TuxPaint_Font_FontFaceStyleName() received NULL\n", __FILE__, __LINE__); fflush(stdout); #endif return (""); @@ -1766,7 +1714,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) #ifndef NO_SDLPANGO if (tpf->typ == FONT_TYPE_PANGO) { - (void) (tpf); + (void)(tpf); /* FIXME */ return (""); @@ -1777,8 +1725,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) return (TTF_FontFaceStyleName(tpf->ttf_font)); #ifdef DEBUG - printf("%s:%d - TuxPaint_Font_FontFaceStyleName() is confused\n", __FILE__, - __LINE__); + printf("%s:%d - TuxPaint_Font_FontFaceStyleName() is confused\n", __FILE__, __LINE__); #endif return (""); @@ -1787,8 +1734,7 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf) #ifndef NO_SDLPANGO -void sdl_color_to_pango_color(SDL_Color sdl_color, - SDLPango_Matrix * pango_color) +void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color) { Uint8 pc[4][4]; diff --git a/src/fonts.h b/src/fonts.h index 651766a7c..c4fe25301 100644 --- a/src/fonts.h +++ b/src/fonts.h @@ -121,10 +121,8 @@ int TuxPaint_Font_FontHeight(TuxPaint_Font * tpf); #ifdef FORKED_FONTS void reliable_write(int fd, const void *buf, size_t count); void run_font_scanner(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, - const char *restrict const locale); -void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer); + SDL_Renderer * renderer, const char *restrict const locale); +void receive_some_font_info(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer); #endif ////////////////////////////////////////////////////////////////////// @@ -192,8 +190,7 @@ TuxPaint_Font *getfonthandle(int desire); int charset_works(TuxPaint_Font * font, const char *s); -TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, - const char *ttffilename, int size); +TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffilename, int size); void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf); const char *TuxPaint_Font_FontFaceFamilyName(TuxPaint_Font * tpf); const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf); @@ -201,12 +198,10 @@ const char *TuxPaint_Font_FontFaceStyleName(TuxPaint_Font * tpf); #ifdef NO_SDLPANGO TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size); #else -void sdl_color_to_pango_color(SDL_Color sdl_color, - SDLPango_Matrix * pango_color); +void sdl_color_to_pango_color(SDL_Color sdl_color, SDLPango_Matrix * pango_color); #endif int load_user_fonts(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer, void *vp, - const char *restrict const locale); + SDL_Renderer * renderer, void *vp, const char *restrict const locale); #endif diff --git a/src/get_fname.c b/src/get_fname.c index 118431bcc..d0a25372b 100644 --- a/src/get_fname.c +++ b/src/get_fname.c @@ -88,6 +88,7 @@ const char *exportdir; char *get_fname(const char *const name, int kind) { char f[512]; + // const char *restrict const dir; const char *dir; diff --git a/src/gifenc.c b/src/gifenc.c index 994ef11d9..94e44491c 100644 --- a/src/gifenc.c +++ b/src/gifenc.c @@ -44,6 +44,7 @@ typedef struct Node Node; static Node *new_node(uint16_t key, int degree) { Node *node = calloc(1, sizeof(*node) + degree * sizeof(Node *)); + if (node) node->key = key; return node; @@ -52,6 +53,7 @@ static Node *new_node(uint16_t key, int degree) static Node *new_trie(int degree, int *nkeys) { Node *root = new_node(0, degree); + /* Create nodes for single pixels. */ for (*nkeys = 0; *nkeys < degree; (*nkeys)++) root->children[*nkeys] = new_node(*nkeys, degree); @@ -75,12 +77,12 @@ static void put_loop(ge_GIF * gif, uint16_t loop); #define OR_ABORT if (res == -1) { fprintf(stderr, "Cannot write to GIF\n"); return(NULL); } #define OR_ABORT2 if (res == -1) { fprintf(stderr, "Cannot write to GIF\n"); return; } -ge_GIF *ge_new_gif(const char *fname, uint16_t width, uint16_t height, - uint8_t * palette, int depth, int loop) +ge_GIF *ge_new_gif(const char *fname, uint16_t width, uint16_t height, uint8_t * palette, int depth, int loop) { int i, r, g, b, v; ssize_t res; ge_GIF *gif = calloc(1, sizeof(*gif) + 2 * width * height); + if (!gif) goto no_gif; gif->w = width; @@ -225,8 +227,7 @@ static void end_key(ge_GIF * gif) gif->offset = gif->partial = 0; } -static void -put_image(ge_GIF * gif, uint16_t w, uint16_t h, uint16_t x, uint16_t y) +static void put_image(ge_GIF * gif, uint16_t w, uint16_t h, uint16_t x, uint16_t y) { int nkeys, key_size, i, j; Node *node, *child, *root; @@ -255,6 +256,7 @@ put_image(ge_GIF * gif, uint16_t w, uint16_t h, uint16_t x, uint16_t y) for (j = x; j < x + w; j++) { uint8_t pixel = gif->frame[i * gif->w + j] & (degree - 1); + child = node->children[pixel]; if (child) { @@ -286,11 +288,11 @@ put_image(ge_GIF * gif, uint16_t w, uint16_t h, uint16_t x, uint16_t y) del_trie(root, degree); } -static int -get_bbox(ge_GIF * gif, uint16_t * w, uint16_t * h, uint16_t * x, uint16_t * y) +static int get_bbox(ge_GIF * gif, uint16_t * w, uint16_t * h, uint16_t * x, uint16_t * y) { int i, j, k; int left, right, top, bottom; + left = gif->w; right = 0; top = gif->h; diff --git a/src/gifenc.h b/src/gifenc.h index a54304cd5..68a364f51 100644 --- a/src/gifenc.h +++ b/src/gifenc.h @@ -15,8 +15,7 @@ typedef struct ge_GIF uint8_t buffer[0xFF]; } ge_GIF; -ge_GIF *ge_new_gif(const char *fname, uint16_t width, uint16_t height, - uint8_t * palette, int depth, int loop); +ge_GIF *ge_new_gif(const char *fname, uint16_t width, uint16_t height, uint8_t * palette, int depth, int loop); void ge_add_frame(ge_GIF * gif, uint16_t delay); void ge_close_gif(ge_GIF * gif); diff --git a/src/i18n.c b/src/i18n.c index 46e096a06..8f026d4bf 100644 --- a/src/i18n.c +++ b/src/i18n.c @@ -64,16 +64,12 @@ static char *android_locale() static char android_locale_buf[32]; JNIEnv *mEnv = Android_JNI_GetEnv(); jclass mLocaleClass = (*mEnv)->FindClass(mEnv, "java/util/Locale"); - jmethodID mGetDefaultMethod = - (*mEnv)->GetStaticMethodID(mEnv, mLocaleClass, "getDefault", - "()Ljava/util/Locale;"); - jobject mLocaleObject = - (*mEnv)->CallStaticObjectMethod(mEnv, mLocaleClass, mGetDefaultMethod); - jmethodID mToStringMethod = - (*mEnv)->GetMethodID(mEnv, mLocaleClass, "toString", - "()Ljava/lang/String;"); - jstring mLocaleString = - (*mEnv)->CallObjectMethod(mEnv, mLocaleObject, mToStringMethod); + jmethodID mGetDefaultMethod = (*mEnv)->GetStaticMethodID(mEnv, mLocaleClass, "getDefault", + "()Ljava/util/Locale;"); + jobject mLocaleObject = (*mEnv)->CallStaticObjectMethod(mEnv, mLocaleClass, mGetDefaultMethod); + jmethodID mToStringMethod = (*mEnv)->GetMethodID(mEnv, mLocaleClass, "toString", + "()Ljava/lang/String;"); + jstring mLocaleString = (*mEnv)->CallObjectMethod(mEnv, mLocaleObject, mToStringMethod); const char *locale = (*mEnv)->GetStringUTFChars(mEnv, mLocaleString, 0); strcpy(android_locale_buf, locale); @@ -494,9 +490,7 @@ static void show_lang_usage(int exitcode) const char *const prg = "tuxpaint"; /* FIXME: All this should REALLY be array-based!!! */ - fprintf(f, - "\n" "Usage: %s [--lang LANGUAGE]\n" "\n" - "LANGUAGE may be one of:\n" + fprintf(f, "\n" "Usage: %s [--lang LANGUAGE]\n" "\n" "LANGUAGE may be one of:\n" /* C */ " english american-english\n" /* ach */ " acholi acoli\n" /* af */ " afrikaans\n" @@ -774,8 +768,7 @@ static void show_locale_usage(FILE * f, const char *const prg) " wa_BE (Walloon)\n" " wo_SN (Wolof)\n" " cy_GB (Welsh Cymraeg)\n" - " xh_ZA (Xhosa)\n" " zam (Zapoteco-Miahuatlan)\n" - " zu_ZA (Zulu)\n" "\n", prg); + " xh_ZA (Xhosa)\n" " zam (Zapoteco-Miahuatlan)\n" " zu_ZA (Zulu)\n" "\n", prg); } /** @@ -819,13 +812,12 @@ static void ctype_utf8(void) #ifndef _WIN32 /* FIXME: should this iterate over more locales? A zapotec speaker may have es_MX.UTF-8 available but not have en_US.UTF-8 for example */ - const char *names[] = - { "en_US.UTF8", "en_US.UTF-8", "UTF8", "UTF-8", "C.UTF-8" }; + const char *names[] = { "en_US.UTF8", "en_US.UTF-8", "UTF8", "UTF-8", "C.UTF-8" }; int i = sizeof(names) / sizeof(names[0]); for (;;) { - if (iswprint((wchar_t) 0xf7)) // division symbol -- which is in Latin-1 :-/ + if (iswprint((wchar_t)0xf7)) // division symbol -- which is in Latin-1 :-/ return; if (--i < 0) break; @@ -844,8 +836,7 @@ static void ctype_utf8(void) */ static const char *language_to_locale(const char *langstr) { - int i = - sizeof language_to_locale_array / sizeof language_to_locale_array[0]; + int i = sizeof language_to_locale_array / sizeof language_to_locale_array[0]; while (i--) { @@ -871,8 +862,7 @@ static const char *language_to_locale(const char *langstr) */ static const char *locale_to_closest_locale(const char *inlocale) { - const int numlocale = - sizeof(language_to_locale_array) / sizeof(language_to_locale_array[0]); + const int numlocale = sizeof(language_to_locale_array) / sizeof(language_to_locale_array[0]); const char *outlocale = NULL; int outlocale_score = 0; int i = 0; @@ -883,8 +873,7 @@ static const char *locale_to_closest_locale(const char *inlocale) { const char *candidate = language_to_locale_array[i].locale; - for (j = 0; j < (int) strlen(inlocale) && j < (int) strlen(candidate); - j++) + for (j = 0; j < (int)strlen(inlocale) && j < (int)strlen(candidate); j++) { if (inlocale[j] != candidate[j]) break; @@ -964,8 +953,7 @@ static void set_langint_from_locale_string(const char *restrict loc) for (i = 0; i < NUM_LANGS && found == 0; i++) { // Case-insensitive (both "pt_BR" and "pt_br" work, etc.) - if (len_baseloc == strlen(lang_prefixes[i]) - && !strncasecmp(straux, lang_prefixes[i], len_baseloc)) + if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(straux, lang_prefixes[i], len_baseloc)) { langint = i; found = 1; @@ -980,8 +968,7 @@ static void set_langint_from_locale_string(const char *restrict loc) for (i = 0; i < NUM_LANGS && found == 0; i++) { // Case-insensitive (both "pt_BR" and "pt_br" work, etc.) - if (len_baseloc == strlen(lang_prefixes[i]) - && !strncasecmp(straux, lang_prefixes[i], len_baseloc)) + if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(straux, lang_prefixes[i], len_baseloc)) { langint = i; found = 1; @@ -1001,8 +988,7 @@ static void set_langint_from_locale_string(const char *restrict loc) for (i = 0; i < NUM_LANGS && found == 0; i++) { // Case-insensitive (both "pt_BR" and "pt_br" work, etc.) - if (len_baseloc == strlen(lang_prefixes[i]) && - !strncasecmp(straux, lang_prefixes[i], strlen(lang_prefixes[i]))) + if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(straux, lang_prefixes[i], strlen(lang_prefixes[i]))) { langint = i; found = 1; @@ -1018,8 +1004,7 @@ static void set_langint_from_locale_string(const char *restrict loc) for (i = 0; i < NUM_LANGS && found == 0; i++) { // Case-insensitive (both "pt_BR" and "pt_br" work, etc.) - if (len_baseloc == strlen(lang_prefixes[i]) - && !strncasecmp(baseloc, lang_prefixes[i], strlen(lang_prefixes[i]))) + if (len_baseloc == strlen(lang_prefixes[i]) && !strncasecmp(baseloc, lang_prefixes[i], strlen(lang_prefixes[i]))) { langint = i; found = 1; @@ -1099,8 +1084,7 @@ void mysetenv(const char *name, const char *value) * @return The Y-nudge value for font rendering in the language. */ -static int set_current_language(const char *restrict loc, - int *ptr_num_wished_langs) +static int set_current_language(const char *restrict loc, int *ptr_num_wished_langs) { int i; int j = 0; @@ -1137,8 +1121,7 @@ static int set_current_language(const char *restrict loc, env = getenv("LC_MESSAGES"); if (env != NULL && env[0] != '\0') { - DEBUG_PRINTF("Language via LC_MESSAGES: %s\n", - getenv("LC_MESSAGES")); + DEBUG_PRINTF("Language via LC_MESSAGES: %s\n", getenv("LC_MESSAGES")); mysetenv("LANGUAGE", getenv("LC_MESSAGES")); } else @@ -1182,6 +1165,7 @@ static int set_current_language(const char *restrict loc, // -- 2022/02/02: Shin-ichi TOYAMA & Pere Pujal i Carabantes char curdir[256]; char f[512]; + getcwd(curdir, sizeof(curdir)); snprintf(f, sizeof(f), "%s%s", curdir, "\\locale"); #ifdef DEBUG @@ -1255,12 +1239,9 @@ static int set_current_language(const char *restrict loc, set_langint_from_locale_string(env_language_lang); wished_langs[j].langint = langint; wished_langs[j].lang_prefix = lang_prefixes[langint]; - wished_langs[j].need_own_font = - search_int_array(langint, lang_use_own_font); - wished_langs[j].need_right_to_left = - search_int_array(langint, lang_use_right_to_left); - wished_langs[j].need_right_to_left_word = - search_int_array(langint, lang_use_right_to_left_word); + wished_langs[j].need_own_font = search_int_array(langint, lang_use_own_font); + wished_langs[j].need_right_to_left = search_int_array(langint, lang_use_right_to_left); + wished_langs[j].need_right_to_left_word = search_int_array(langint, lang_use_right_to_left_word); for (i = 0; lang_y_nudge[i][0] != -1; i++) { // printf("lang_y_nudge[%d][0] = %d\n", i, lang_y_nudge[i][0]); @@ -1294,15 +1275,13 @@ static int set_current_language(const char *restrict loc, #ifdef DEBUG fprintf(stderr, "DEBUG: Language is %s (%d) %s/%s\n", - lang_prefix, langint, need_right_to_left ? "(RTL)" : "", - need_right_to_left_word ? "(RTL words)" : ""); + lang_prefix, langint, need_right_to_left ? "(RTL)" : "", need_right_to_left_word ? "(RTL words)" : ""); fflush(stderr); #endif free(oldloc); - DEBUG_PRINTF("lang_prefixes[%d] is \"%s\"\n", get_current_language(), - lang_prefixes[get_current_language()]); + DEBUG_PRINTF("lang_prefixes[%d] is \"%s\"\n", get_current_language(), lang_prefixes[get_current_language()]); *ptr_num_wished_langs = num_wished_langs; @@ -1321,8 +1300,7 @@ static int set_current_language(const char *restrict loc, * @param int * a place to return the number of languages we want to use, when scanning stamp descriptions * @return Y-nudge */ -int setup_i18n(const char *restrict lang, const char *restrict locale, - int *num_wished_langs) +int setup_i18n(const char *restrict lang, const char *restrict locale, int *num_wished_langs) { DEBUG_PRINTF("lang %p, locale %p\n", lang, locale); DEBUG_PRINTF("lang \"%s\", locale \"%s\"\n", lang, locale); @@ -1364,6 +1342,7 @@ int setup_i18n(const char *restrict lang, const char *restrict locale, int smash_i18n(void) { int tmp; + return set_current_language("C", &tmp); } #endif diff --git a/src/i18n.h b/src/i18n.h index 8a75e5dd5..032a67221 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -206,9 +206,8 @@ extern w_langs wished_langs[255]; /* Function prototypes: */ int get_current_language(void); -int setup_i18n(const char *restrict lang, const char *restrict locale, - int *ptr_num_wished_languages) MUST_CHECK; -void mysetenv(const char *name, const char *value); +int setup_i18n(const char *restrict lang, const char *restrict locale, int *ptr_num_wished_languages) MUST_CHECK; + void mysetenv(const char *name, const char *value); #ifdef NO_SDLPANGO int smash_i18n(void) MUST_CHECK; diff --git a/src/im.c b/src/im.c index ad20bc16a..c796939c9 100644 --- a/src/im.c +++ b/src/im.c @@ -258,7 +258,7 @@ static void wcs_lshift(wchar_t *s, size_t count) */ static void wcs_pull(wchar_t *s, size_t count) { - int peg = (int) wcslen(s) - (int) count; + int peg = (int)wcslen(s) - (int)count; if (peg < 0) peg = 0; @@ -311,7 +311,7 @@ static void sm_free(STATE_MACHINE * sm) { int i = 0; - for (i = 0; i < (int) sm->next_maxsize; i++) + for (i = 0; i < (int)sm->next_maxsize; i++) { STATE_MACHINE *next_state = sm->next[i].state; @@ -358,8 +358,7 @@ static STATE_MACHINE *sm_search_shallow(STATE_MACHINE * sm, char key) SM_WITH_KEY smk = { key, NULL }; SM_WITH_KEY *smk_found; - smk_found = - bsearch(&smk, sm->next, sm->next_size, sizeof(SM_WITH_KEY), swk_compare); + smk_found = bsearch(&smk, sm->next, sm->next_size, sizeof(SM_WITH_KEY), swk_compare); if (!smk_found) return NULL; @@ -381,10 +380,9 @@ static STATE_MACHINE *sm_search_shallow(STATE_MACHINE * sm, char key) * @return Found unicode character sequence output of the last state. */ static const wchar_t *sm_search(STATE_MACHINE * start, wchar_t *key, - int *matched, STATE_MACHINE ** penult, - STATE_MACHINE ** end) + int *matched, STATE_MACHINE ** penult, STATE_MACHINE ** end) { - STATE_MACHINE *sm = sm_search_shallow(start, (char) *key); + STATE_MACHINE *sm = sm_search_shallow(start, (char)*key); const wchar_t *unicode; /* No match - stop recursion */ @@ -418,8 +416,7 @@ static void sm_sort_shallow(STATE_MACHINE * sm) /** * Add a single sequence-to-unicode path to the state machine. */ -static int sm_add(STATE_MACHINE * sm, char *seq, const wchar_t *unicode, - char flag) +static int sm_add(STATE_MACHINE * sm, char *seq, const wchar_t *unicode, char flag) { STATE_MACHINE *sm_found = sm_search_shallow(sm, seq[0]); @@ -432,10 +429,10 @@ static int sm_add(STATE_MACHINE * sm, char *seq, const wchar_t *unicode, fprintf(stderr, "Unicode sequence "); for (i = 0; i < wcslen(sm->output); i++) - fprintf(stderr, "%04X ", (int) sm->output[i]); + fprintf(stderr, "%04X ", (int)sm->output[i]); fprintf(stderr, " already defined, overriding with "); for (i = 0; i < wcslen(unicode); i++) - fprintf(stderr, "%04X ", (int) unicode[i]); + fprintf(stderr, "%04X ", (int)unicode[i]); fprintf(stderr, "\n"); } wcscpy(sm->output, unicode); @@ -446,7 +443,7 @@ static int sm_add(STATE_MACHINE * sm, char *seq, const wchar_t *unicode, /* The key doesn't exist yet */ if (!sm_found) { - int index = (int) sm->next_size; + int index = (int)sm->next_size; SM_WITH_KEY *next = &sm->next[index]; /* Add the key */ @@ -516,8 +513,7 @@ static int charmap_init(CHARMAP * cm) * * @return 0 if no error, 1 if error. */ -static int charmap_add(CHARMAP * cm, int section, char *seq, - const wchar_t *unicode, char *flag) +static int charmap_add(CHARMAP * cm, int section, char *seq, const wchar_t *unicode, char *flag) { if (section >= MAX_SECTIONS) { @@ -528,7 +524,7 @@ static int charmap_add(CHARMAP * cm, int section, char *seq, /* For now, we only utilize one-character flags */ if (strlen(flag) > 1) { - fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int) (intptr_t) unicode); //EP added (intptr_t) to avoid warning on x64 + fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int)(intptr_t) unicode); //EP added (intptr_t) to avoid warning on x64 } return sm_add(&cm->sections[section], seq, unicode, flag[0]); @@ -635,7 +631,7 @@ static int charmap_load(CHARMAP * cm, const char *path) fwprintf(stderr, L"Unable to add sequence '%ls', unicode ", buf); for (i = 0; i < wcslen(unicode); i++) - fwprintf(stderr, L"%04X ", (int) unicode[i]); + fwprintf(stderr, L"%04X ", (int)unicode[i]); fwprintf(stderr, L"in section %d\n", section); #endif #endif @@ -679,15 +675,13 @@ static const wchar_t *charmap_search(CHARMAP * cm, wchar_t *s) /* Determine the starting state based on the charmap's active section */ section = cm->section; - if (!IN_RANGE(0, section, (int) ARRAYLEN(cm->sections))) + if (!IN_RANGE(0, section, (int)ARRAYLEN(cm->sections))) section = 0; start = &cm->sections[section]; cm->match_state = NULL; cm->match_state_prev = NULL; - unicode = - sm_search(start, s, &cm->match_count, &cm->match_state_prev, - &cm->match_state); + unicode = sm_search(start, s, &cm->match_count, &cm->match_state_prev, &cm->match_state); /** * Determine whether the match is final. A match is considered to be final @@ -701,7 +695,7 @@ static const wchar_t *charmap_search(CHARMAP * cm, wchar_t *s) * final state we possibly can. */ cm->match_is_final = 0; - if (cm->match_count < (int) wcslen(s)) + if (cm->match_count < (int)wcslen(s)) { cm->match_is_final = 1; } @@ -713,7 +707,7 @@ static const wchar_t *charmap_search(CHARMAP * cm, wchar_t *s) cm->match_is_final = 1; cm->match_stats |= MATCH_STAT_NOMOSTATES; } - if (cm->match_count == (int) wcslen(s)) + if (cm->match_count == (int)wcslen(s)) { cm->match_stats |= MATCH_STAT_NOMOBUF; } @@ -830,8 +824,7 @@ int im_read(IM_DATA * im, SDL_Event event) redraw = im_event_c(im, event); #ifdef IM_DEBUG - wprintf(L"* [%8ls] [%8ls] %2d %2d (%2d)\n", im->s, im->buf, wcslen(im->s), - wcslen(im->buf), im->redraw); + wprintf(L"* [%8ls] [%8ls] %2d %2d (%2d)\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf), im->redraw); #endif return redraw; @@ -983,8 +976,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event) if (charmap_load(&cm, lang_file)) { - fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", - lang_file); + fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; return im_event_c(im, event); } @@ -1001,7 +993,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event) /* Discard redraw characters, so they can be redrawn */ - if ((int) wcslen(im->s) < im->redraw) + if ((int)wcslen(im->s) < im->redraw) im->redraw = wcslen(im->s); wcs_lshift(im->s, (wcslen(im->s) - im->redraw)); @@ -1055,8 +1047,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event) /* Actual character processing */ default: - if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE - || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) + if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) { /* English mode */ if (cm.section == SEC_ENGLISH) @@ -1081,8 +1072,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event) const wchar_t *us = charmap_search(&cm, im->buf); #ifdef IM_DEBUG - wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), - wcslen(im->buf)); + wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf)); #endif /* Match was found? */ @@ -1122,7 +1112,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event) cm.match_is_final = 0; } /* If the matched characters didn't consume all, it's own state */ - else if ((size_t) cm.match_count != wcslen(im->buf)) + else if ((size_t)cm.match_count != wcslen(im->buf)) { #ifdef IM_DEBUG wprintf(L" 2b (%2d)\n", cm.match_count); @@ -1209,8 +1199,7 @@ static int im_event_th(IM_DATA * im, SDL_Event event) if (charmap_load(&cm, lang_file)) { - fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", - lang_file); + fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; return im_event_c(im, event); } @@ -1227,7 +1216,7 @@ static int im_event_th(IM_DATA * im, SDL_Event event) /* Discard redraw characters, so they can be redrawn */ - if ((int) wcslen(im->s) < im->redraw) + if ((int)wcslen(im->s) < im->redraw) im->redraw = wcslen(im->s); wcs_lshift(im->s, (wcslen(im->s) - im->redraw)); @@ -1304,8 +1293,7 @@ static int im_event_th(IM_DATA * im, SDL_Event event) const wchar_t *us = charmap_search(&cm, im->buf); #ifdef IM_DEBUG - wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), - wcslen(im->buf)); + wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf)); #endif /* Match was found? */ @@ -1345,7 +1333,7 @@ static int im_event_th(IM_DATA * im, SDL_Event event) cm.match_is_final = 0; } /* If the matched characters didn't consume all, it's own state */ - else if ((size_t) cm.match_count != wcslen(im->buf)) + else if ((size_t)cm.match_count != wcslen(im->buf)) { #ifdef IM_DEBUG wprintf(L" 2b (%2d)\n", cm.match_count); @@ -1431,8 +1419,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event) if (charmap_load(&cm, lang_file)) { - fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", - lang_file); + fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; return im_event_c(im, event); } @@ -1449,7 +1436,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event) /* Discard redraw characters, so they can be redrawn */ - if ((int) wcslen(im->s) < im->redraw) + if ((int)wcslen(im->s) < im->redraw) im->redraw = wcslen(im->s); wcs_lshift(im->s, (wcslen(im->s) - im->redraw)); @@ -1506,8 +1493,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event) /* Actual character processing */ default: - if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE - || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) + if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) { /* English mode */ if (cm.section == SEC_ENGLISH) @@ -1532,8 +1518,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event) const wchar_t *us = charmap_search(&cm, im->buf); #ifdef IM_DEBUG - wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), - wcslen(im->buf)); + wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf)); #endif /* Match was found? */ @@ -1573,7 +1558,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event) cm.match_is_final = 0; } /* If the matched characters didn't consume all, it's own state */ - else if ((size_t) cm.match_count != wcslen(im->buf)) + else if ((size_t)cm.match_count != wcslen(im->buf)) { #ifdef IM_DEBUG wprintf(L" 2b (%2d)\n", cm.match_count); @@ -1628,15 +1613,14 @@ static int im_event_ko_isvowel(CHARMAP * cm, wchar_t c) /* Determine the starting state based on the charmap's active section */ section = cm->section; - if (!IN_RANGE(0, section, (int) ARRAYLEN(cm->sections))) + if (!IN_RANGE(0, section, (int)ARRAYLEN(cm->sections))) section = 0; start = &cm->sections[section]; - next = sm_search_shallow(start, (char) c); + next = sm_search_shallow(start, (char)c); unicode = next ? next->output : NULL; - return (unicode && wcslen(unicode) == 1 && 0x314F <= unicode[0] - && unicode[0] <= 0x3163); + return (unicode && wcslen(unicode) == 1 && 0x314F <= unicode[0] && unicode[0] <= 0x3163); } @@ -1685,8 +1669,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event) if (charmap_load(&cm, lang_file)) { - fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", - lang_file); + fprintf(stderr, "Unable to load %s, defaulting to im_event_c\n", lang_file); im->lang = LANG_DEFAULT; return im_event_c(im, event); } @@ -1703,7 +1686,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event) /* Discard redraw characters, so they can be redrawn */ - if ((int) wcslen(im->s) < im->redraw) + if ((int)wcslen(im->s) < im->redraw) im->redraw = wcslen(im->s); wcs_lshift(im->s, (wcslen(im->s) - im->redraw)); @@ -1758,8 +1741,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event) /* Actual character processing */ default: - if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE - || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) + if (event.type == SDL_TEXTINPUT || ks.sym == SDLK_BACKSPACE || ks.sym == SDLK_RETURN || ks.sym == SDLK_TAB) { /* English mode */ if (cm.section == SEC_ENGLISH) @@ -1783,8 +1765,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event) const wchar_t *us = charmap_search(&cm, bp); #ifdef IM_DEBUG - wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), - wcslen(im->buf)); + wprintf(L" [%8ls] [%8ls] %2d %2d\n", im->s, im->buf, wcslen(im->s), wcslen(im->buf)); #endif /* Match was found? */ @@ -1876,7 +1857,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event) cm.match_is_final = 0; } /* If the matched characters didn't consume all, it's own state */ - else if ((size_t) cm.match_count != wcslen(bp)) + else if ((size_t)cm.match_count != wcslen(bp)) { #ifdef IM_DEBUG wprintf(L" 2b (%2d)\n", cm.match_count); diff --git a/src/indent.sh b/src/indent.sh new file mode 100755 index 000000000..79382e843 --- /dev/null +++ b/src/indent.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Indent Tux Paint source files + +echo "Indenting src/*.c" +find . -name "*.c" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \; + +echo "Indenting src/*.h" +find . -name "*.h" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \; + +echo "Indenting magic/src/*.c" +find ../magic/src/ -name "*.c" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \; + +echo "Indenting magic/src/*.h" +find ../magic/src/ -name "*.h" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \; + diff --git a/src/onscreen_keyboard.c b/src/onscreen_keyboard.c index 1bfb2a8e1..4fd425ebf 100644 --- a/src/onscreen_keyboard.c +++ b/src/onscreen_keyboard.c @@ -61,8 +61,7 @@ static void draw_keyboard(on_screen_keyboard * keyboard); static osk_key *find_key(on_screen_keyboard * keyboard, int x, int y); static void set_key(osk_key * orig, osk_key * dest, int firsttime); static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name); -static struct osk_layout *load_layout(on_screen_keyboard * keyboard, - char *layout_name); +static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layout_name); #ifdef DEBUG_OSK_COMPOSEMAP static void print_composemap(osk_composenode * composemap, char *sp); @@ -91,9 +90,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_Surface * BLANK_oskdel, SDL_Surface * BLANK_osktab, SDL_Surface * BLANK_oskenter, - SDL_Surface * BLANK_oskcapslock, - SDL_Surface * BLANK_oskshift, - int disable_change) + SDL_Surface * BLANK_oskcapslock, SDL_Surface * BLANK_oskshift, int disable_change) { SDL_Surface *surface; SDL_Surface *button_up, *button_down; @@ -113,8 +110,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, layout = load_layout(keyboard, layout_name); if (!layout) { - fprintf(stderr, "Error trying to load the required layout %s\n", - layout_name); + fprintf(stderr, "Error trying to load the required layout %s\n", layout_name); layout = load_layout(keyboard, strdup("default.layout")); if (!layout) { @@ -142,17 +138,15 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, #ifdef OSK_DEBUG printf ("%d x %d layout of %d x %d buttons won't fit within %d x %d pixel area...\n", - layout->width, layout->height, BLANK_button_up->w, BLANK_button_up->h, - layout_avail_width, layout_avail_height); + layout->width, layout->height, BLANK_button_up->w, BLANK_button_up->h, layout_avail_width, layout_avail_height); #endif - max_w = (float) layout_avail_width / (float) layout->width; - max_h = (float) layout_avail_height / (float) layout->height; + max_w = (float)layout_avail_width / (float)layout->width; + max_h = (float)layout_avail_height / (float)layout->height; #ifdef OSK_DEBUG printf("...want (%d / %d) x (%d x %d) = %.2f x %.2f buttons...\n", - layout_avail_width, layout->width, - layout_avail_height, layout->height, max_w, max_h); + layout_avail_width, layout->width, layout_avail_height, layout->height, max_w, max_h); #endif if (max_w > max_h) @@ -160,8 +154,8 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, if (max_h > max_w) max_h = max_w; - scale_w = (float) max_w / (float) BLANK_button_up->w; - scale_h = (float) max_h / (float) BLANK_button_up->h; + scale_w = (float)max_w / (float)BLANK_button_up->w; + scale_h = (float)max_h / (float)BLANK_button_up->h; #ifdef OSK_DEBUG printf("...so scaling by w=%.2f & h=%.2f\n", scale_w, scale_h); @@ -196,8 +190,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, layout->width * button_up->w, layout->height * button_up->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); if (!surface) { fprintf(stderr, "Error creating the onscreen keyboard surface\n"); @@ -251,8 +244,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, keyboard->layout->bgcolor.r, - keyboard->layout->bgcolor.g, - keyboard->layout->bgcolor.b)); + keyboard->layout->bgcolor.g, keyboard->layout->bgcolor.b)); keybd_prepare(keyboard); @@ -260,8 +252,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, return keyboard; } -static struct osk_layout *load_layout(on_screen_keyboard * keyboard, - char *layout_name) +static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layout_name) { FILE *fi; int hlayout_loaded; @@ -303,8 +294,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, fi = fopen(filename, "r"); if (fi == NULL) { - fprintf(stderr, "Can't open either %s nor %s\n", layout_name, - filename); + fprintf(stderr, "Can't open either %s nor %s\n", layout_name, filename); /* Fallback to default */ snprintf(filename, 255, "%sosk/default.layout", DATA_PREFIX); fi = fopen(filename, "r"); @@ -424,8 +414,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name) fi = fopen(filename, "r"); if (fi == NULL) { - fprintf(stderr, "Can't open either %s nor %s\n", hlayout_name, - filename); + fprintf(stderr, "Can't open either %s nor %s\n", hlayout_name, filename); layout->keys = NULL; free(filename); return; @@ -534,8 +523,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name) layout->keys[line_number][i].shift_altgr_label = NULL; } } - else if (width && height && allocated && strncmp(line, "KEY ", 4) == 0 - && key_number < width) + else if (width && height && allocated && strncmp(line, "KEY ", 4) == 0 && key_number < width) { plain_label = malloc(sizeof(char) * 64); top_label = malloc(sizeof(char) * 64); @@ -546,17 +534,14 @@ void load_hlayout(osk_layout * layout, char *hlayout_name) "%s %i %i.%i %s %s %s %s %i", key, &keycode, - &key_width, &key_width_decimal, plain_label, top_label, - altgr_label, shift_altgr_label, &shiftcaps); + &key_width, &key_width_decimal, plain_label, top_label, altgr_label, shift_altgr_label, &shiftcaps); layout->keys[line_number][key_number].keycode = keycode; - layout->keys[line_number][key_number].width = - (float) 0.1 *key_width_decimal + key_width; + layout->keys[line_number][key_number].width = (float)0.1 *key_width_decimal + key_width; layout->keys[line_number][key_number].plain_label = plain_label; layout->keys[line_number][key_number].top_label = top_label; layout->keys[line_number][key_number].altgr_label = altgr_label; - layout->keys[line_number][key_number].shift_altgr_label = - shift_altgr_label; + layout->keys[line_number][key_number].shift_altgr_label = shift_altgr_label; layout->keys[line_number][key_number].shiftcaps = shiftcaps; layout->keys[line_number][key_number].stick = 0; key_number++; @@ -653,9 +638,7 @@ void load_keymap(osk_layout * layout, char *keymap_name) /* FIXME: Why is the us-intl keymap duplicating the two first entries of every keycode? */ /* And why is the arabic keymap using the 5th and 6th entries as plain/shifted keys? */ - readed = - sscanf(line, "keycode %i = %s %s %s %s", &keycode, ksname1, ksname2, - ksname3, ksname4); + readed = sscanf(line, "keycode %i = %s %s %s %s", &keycode, ksname1, ksname2, ksname3, ksname4); if (readed == 5 && keycode > 8 && keycode < 256) { @@ -695,8 +678,7 @@ void load_keymap(osk_layout * layout, char *keymap_name) } /* Scans a line of keysyms and result and classifies them. */ -static void gettokens(char *line, char *delim, char **pointer, - osk_composenode * composenode, osk_layout * layout) +static void gettokens(char *line, char *delim, char **pointer, osk_composenode * composenode, osk_layout * layout) { int i; char *tok; @@ -763,9 +745,7 @@ static void gettokens(char *line, char *delim, char **pointer, } composenode->size = composenode->size + 1; - composenode->childs = - realloc(composenode->childs, - composenode->size * sizeof(osk_composenode *)); + composenode->childs = realloc(composenode->childs, composenode->size * sizeof(osk_composenode *)); mbstowcs(wtok, tok, 255); auxnode = malloc(sizeof(osk_composenode)); @@ -776,8 +756,7 @@ static void gettokens(char *line, char *delim, char **pointer, /* printf("size %d, keysym %ls =>", composenode->size, composenode->childs[composenode->size - 1]->keysym); */ - gettokens(NULL, delim, pointer, - composenode->childs[composenode->size - 1], layout); + gettokens(NULL, delim, pointer, composenode->childs[composenode->size - 1], layout); free(tok); return; } @@ -808,8 +787,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name) fi = fopen(filename, "r"); if (fi == NULL) { - fprintf(stderr, "Can't open either %s nor %s\n", composemap_name, - filename); + fprintf(stderr, "Can't open either %s nor %s\n", composemap_name, filename); layout->keys = NULL; free(filename); return; @@ -832,7 +810,7 @@ static void load_composemap(osk_layout * layout, char *composemap_name) if (is_blank_or_comment(line)) continue; - gettokens(line, (char *) ">< \t", pointer, layout->composemap, layout); + gettokens(line, (char *)">< \t", pointer, layout->composemap, layout); } fclose(fi); @@ -917,8 +895,7 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name) fi = fopen(filename, "r"); if (fi == NULL) { - fprintf(stderr, "Can't open either %s nor %s\n", keysymdefs_name, - filename); + fprintf(stderr, "Can't open either %s nor %s\n", keysymdefs_name, filename); layout->keysymdefs = NULL; free(filename); return; @@ -939,15 +916,13 @@ static void load_keysymdefs(osk_layout * layout, char *keysymdefs_name) continue; layout->sizeofkeysymdefs = i; - layout->keysymdefs = - realloc(layout->keysymdefs, sizeof(keysymdefs) * (i + 1)); + layout->keysymdefs = realloc(layout->keysymdefs, sizeof(keysymdefs) * (i + 1)); /* Some keysyms doesn't correspond to any unicode value, ej. BackSpace */ layout->keysymdefs[i].unicode = 0; layout->keysymdefs[i].mnemo = malloc(sizeof(char) * 128); sscanf(line, "#define XK_%s %x /* U+%x", - layout->keysymdefs[i].mnemo, &layout->keysymdefs[i].keysym, - &layout->keysymdefs[i].unicode); + layout->keysymdefs[i].mnemo, &layout->keysymdefs[i].keysym, &layout->keysymdefs[i].unicode); i++; } @@ -1004,8 +979,7 @@ static int keysym2unicode(int keysym, on_screen_keyboard * keyboard) * This software is in the public domain. Share and enjoy! */ /* first check for Latin-1 characters (1:1 mapping) */ - if ((keysym >= 0x0020 && keysym <= 0x007e) - || (keysym >= 0x00a0 && keysym <= 0x00ff)) + if ((keysym >= 0x0020 && keysym <= 0x007e) || (keysym >= 0x00a0 && keysym <= 0x00ff)) return keysym; /* also check for directly encoded 24-bit UCS characters */ @@ -1023,9 +997,7 @@ static int keysym2unicode(int keysym, on_screen_keyboard * keyboard) /* Searches in the tree for composing stuff */ -static void get_composed_keysym(on_screen_keyboard * keyboard, - osk_composenode * composenode, - wchar_t *keysym) +static void get_composed_keysym(on_screen_keyboard * keyboard, osk_composenode * composenode, wchar_t *keysym) { int i; @@ -1145,43 +1117,37 @@ static void keybd_prepare(on_screen_keyboard * keyboard) if (keyboard->layout->fontpath) { /* First try if it is an absolute path */ - keyboard->osk_fonty = - TTF_OpenFont(keyboard->layout->fontpath, font_height); + keyboard->osk_fonty = TTF_OpenFont(keyboard->layout->fontpath, font_height); if (keyboard->osk_fonty == NULL) { /* Now trying if it is relative to DATA_PREFIX/fonts/ */ - snprintf(fontname, 255, "%s/fonts/%s", DATA_PREFIX, - keyboard->layout->fontpath); + snprintf(fontname, 255, "%s/fonts/%s", DATA_PREFIX, keyboard->layout->fontpath); keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); if (keyboard->osk_fonty == NULL) { /* Perhaps it is relative to DATA_PREFIX only? */ - snprintf(fontname, 255, "%s/%s", DATA_PREFIX, - keyboard->layout->fontpath); + snprintf(fontname, 255, "%s/%s", DATA_PREFIX, keyboard->layout->fontpath); keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); if (keyboard->osk_fonty == NULL) { /* Or to DATA_PREFIX/fonts/locale/ ? */ - snprintf(fontname, 255, "%s/fonts/locale/%s", DATA_PREFIX, - keyboard->layout->fontpath); + snprintf(fontname, 255, "%s/fonts/locale/%s", DATA_PREFIX, keyboard->layout->fontpath); keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); - if (keyboard->osk_fonty == NULL) - { - /* Fonts are in assets "data" dir in Android builds */ - snprintf(fontname, 255, "data/fonts/%s", - keyboard->layout->fontpath); - keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); - if (keyboard->osk_fonty == NULL) - { - /* Fonts are in assets "data" dir in Android builds, checking locale dir */ - snprintf(fontname, 255, "data/fonts/locale/%s", - keyboard->layout->fontpath); - keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); - } - } - } - } + if (keyboard->osk_fonty == NULL) + { + /* Fonts are in assets "data" dir in Android builds */ + snprintf(fontname, 255, "data/fonts/%s", keyboard->layout->fontpath); + keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); + if (keyboard->osk_fonty == NULL) + { + /* Fonts are in assets "data" dir in Android builds, checking locale dir */ + snprintf(fontname, 255, "data/fonts/locale/%s", keyboard->layout->fontpath); + keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); + } + } + } + } } } @@ -1193,17 +1159,16 @@ static void keybd_prepare(on_screen_keyboard * keyboard) if (keyboard->osk_fonty == NULL) { - /* Also for Android */ - sprintf(fontname, "data/fonts/FreeSansBold.ttf"); - keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); + /* Also for Android */ + sprintf(fontname, "data/fonts/FreeSansBold.ttf"); + keyboard->osk_fonty = TTF_OpenFont(fontname, font_height); } } if (keyboard->osk_fonty == NULL) { fprintf(stderr, "\nError: Can't open the font!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); free(fontname); exit(1); } @@ -1213,8 +1178,7 @@ static void keybd_prepare(on_screen_keyboard * keyboard) } -static void apply_surface(int x, int y, SDL_Surface * source, - SDL_Surface * destination, SDL_Rect * clip) +static void apply_surface(int x, int y, SDL_Surface * source, SDL_Surface * destination, SDL_Rect * clip) { SDL_Rect offset; @@ -1266,8 +1230,7 @@ static SDL_Surface *stretch_surface(SDL_Surface * orig, int width) width, orig->h, orig->format->BitsPerPixel, - orig->format->Rmask, orig->format->Gmask, - orig->format->Bmask, 0); + orig->format->Rmask, orig->format->Gmask, orig->format->Bmask, 0); SDL_BlitSurface(orig, NULL, dest, NULL); rect.y = 0; @@ -1359,38 +1322,26 @@ static void draw_key(osk_key key, on_screen_keyboard * keyboard, int hot) if (strncmp("NULL", text, 4) != 0 && key.keycode != 0) { if (hot) - skey = - stretch_surface(keyboard->button_down, - key.width * keyboard->button_down->w); + skey = stretch_surface(keyboard->button_down, key.width * keyboard->button_down->w); else if (key.stick) - skey = - stretch_surface(keyboard->button_hold, - key.width * keyboard->button_hold->w); + skey = stretch_surface(keyboard->button_hold, key.width * keyboard->button_hold->w); else { if (key.keycode == 1 || key.keycode == 2) { if (keyboard->disable_change) - skey = - stretch_surface(keyboard->button_off, - key.width * keyboard->button_off->w); + skey = stretch_surface(keyboard->button_off, key.width * keyboard->button_off->w); else - skey = - stretch_surface(keyboard->button_nav, - key.width * keyboard->button_nav->w); + skey = stretch_surface(keyboard->button_nav, key.width * keyboard->button_nav->w); } else - skey = - stretch_surface(keyboard->button_up, - key.width * keyboard->button_up->w); + skey = stretch_surface(keyboard->button_up, key.width * keyboard->button_up->w); } } else - skey = - stretch_surface(keyboard->button_off, - key.width * keyboard->button_off->w); + skey = stretch_surface(keyboard->button_off, key.width * keyboard->button_off->w); apply_surface(key.x, key.y, skey, keyboard->surface, NULL); @@ -1452,8 +1403,7 @@ static void label_key(osk_key key, on_screen_keyboard * keyboard) } } - else if (modstate & KMOD_RALT && modstate & KMOD_CAPS - && !(modstate & KMOD_SHIFT)) + else if (modstate & KMOD_RALT && modstate & KMOD_CAPS && !(modstate & KMOD_SHIFT)) { if (key.shiftcaps) text = strdup(key.shift_altgr_label); @@ -1486,8 +1436,7 @@ static void label_key(osk_key key, on_screen_keyboard * keyboard) else if (strncmp("CAPSLOCK", text, 8) == 0) { - apply_surface(key.x, key.y, keyboard->oskcapslock, keyboard->surface, - NULL); + apply_surface(key.x, key.y, keyboard->oskcapslock, keyboard->surface, NULL); } else if (strncmp("SHIFT", text, 5) == 0) @@ -1497,9 +1446,7 @@ static void label_key(osk_key key, on_screen_keyboard * keyboard) else if (strncmp("SPACE", text, 5) != 0 && strncmp("NULL", text, 4) != 0) { - messager = - TTF_RenderUTF8_Blended(keyboard->osk_fonty, text, - keyboard->layout->fgcolor); + messager = TTF_RenderUTF8_Blended(keyboard->osk_fonty, text, keyboard->layout->fgcolor); apply_surface(key.x + 5, key.y, messager, keyboard->surface, NULL); SDL_FreeSurface(messager); @@ -1516,12 +1463,10 @@ static osk_key *find_key(on_screen_keyboard * keyboard, int x, int y) key = NULL; for (j = 0; j < keyboard->layout->height; j++) { - if (keyboard->layout->keys[j][0].y < y - && keyboard->layout->keys[j][0].y + keyboard->button_up->h > y) + if (keyboard->layout->keys[j][0].y < y && keyboard->layout->keys[j][0].y + keyboard->button_up->h > y) for (i = 0; i < keyboard->layout->width; i++) if (keyboard->layout->keys[j][i].x < x && - keyboard->layout->keys[j][i].x + - keyboard->layout->keys[j][i].width * keyboard->button_up->w > x) + keyboard->layout->keys[j][i].x + keyboard->layout->keys[j][i].width * keyboard->button_up->w > x) { key = &keyboard->layout->keys[j][i]; return key; @@ -1629,8 +1574,7 @@ static char *find_keysym(osk_key key, on_screen_keyboard * keyboard) } } - else if (modstate & KMOD_RALT && modstate & KMOD_CAPS - && !(modstate & KMOD_SHIFT)) + else if (modstate & KMOD_RALT && modstate & KMOD_CAPS && !(modstate & KMOD_SHIFT)) { if (key.shiftcaps) keysym = keysyms.shiftaltgr; @@ -1650,8 +1594,7 @@ static char *find_keysym(osk_key key, on_screen_keyboard * keyboard) } /* We lose the SDL ModState by leaving and entering the tuxpaint window, so using a custom state */ -static int handle_keymods(char *keysym, osk_key * key, - on_screen_keyboard * keyboard) +static int handle_keymods(char *keysym, osk_key * key, on_screen_keyboard * keyboard) { SDL_Keymod mod; SDL_Event ev; @@ -1688,8 +1631,7 @@ static int handle_keymods(char *keysym, osk_key * key, /* Seems ISO_Level3_Shift and ISO_Next_Group are used too for right Alt */ else if (strncmp("ISO_Level3_Shift", keysym, 16) == 0 || - strncmp("ISO_Next_Group", keysym, 14) == 0 - || strncmp("ALT_R", keysym, 5) == 0) + strncmp("ISO_Next_Group", keysym, 14) == 0 || strncmp("ALT_R", keysym, 5) == 0) { if (mod & KMOD_RALT) { @@ -1904,10 +1846,10 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y) wkeysym = malloc(sizeof(wchar_t) * (strlen(keysym) + 1)); - mbsrtowcs(wkeysym, (const char **) &keysym, strlen(keysym) + 1, NULL); + mbsrtowcs(wkeysym, (const char **)&keysym, strlen(keysym) + 1, NULL); #ifdef OSK_DEBUG - printf("wkeysym %ls %i\n\n", wkeysym, (int) wcslen(wkeysym)); + printf("wkeysym %ls %i\n\n", wkeysym, (int)wcslen(wkeysym)); #endif @@ -1932,8 +1874,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y) event.text.text[0] = '\r'; event.text.text[1] = '\0'; } - else if (wcsncmp(L"Tab", ks, 3) == 0 - || wcsncmp(L"ISO_Left_Tab", ks, 12) == 0) + else if (wcsncmp(L"Tab", ks, 3) == 0 || wcsncmp(L"ISO_Left_Tab", ks, 12) == 0) { event.key.keysym.sym = SDLK_TAB; event.text.text[0] = '\t'; @@ -1966,7 +1907,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y) wchar_t buf[2]; iwc = keysym2unicode(mnemo2keysym(mnemo, keyboard), keyboard); - buf[0] = (wchar_t) iwc; + buf[0] = (wchar_t)iwc; buf[1] = L'\0'; #ifdef OSK_DEBUG @@ -1979,7 +1920,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y) printf("len = %d\n", len); printf("event.text.text = \"%s\"\n", event.text.text); #else - len = len; /* Avoid 'set but not used' warning */ + len = len; /* Avoid 'set but not used' warning */ #endif } diff --git a/src/onscreen_keyboard.h b/src/onscreen_keyboard.h index 1db4f99f0..dd88b8d1b 100644 --- a/src/onscreen_keyboard.h +++ b/src/onscreen_keyboard.h @@ -156,15 +156,12 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_Surface * BLANK_oskdel, SDL_Surface * BLANK_osktab, SDL_Surface * BLANK_oskenter, - SDL_Surface * BLANK_oskcapslock, - SDL_Surface * BLANK_oskshift, - int disable_change); + SDL_Surface * BLANK_oskcapslock, SDL_Surface * BLANK_oskshift, int disable_change); struct osk_layout *osk_load_layout(char *layout_name); void osk_get_layout_data(char *layout_name, int *layout_w, int *layout_h, - char *layout_buttons, char *layout_labels, - char *layout_keycodes); + char *layout_buttons, char *layout_labels, char *layout_keycodes); void osk_reset(on_screen_keyboard * osk); struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y); void osk_released(on_screen_keyboard * osk); diff --git a/src/pixels.c b/src/pixels.c index 49e1a549f..14ac0b32a 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -37,9 +37,7 @@ static void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) { // Set a pointer to the exact location in memory of the pixel p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ @@ -60,9 +58,7 @@ static void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) { // Set a pointer to the exact location in memory of the pixel p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ @@ -83,9 +79,7 @@ static void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) { // Set a pointer to the exact location in memory of the pixel p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ @@ -118,9 +112,7 @@ static void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel) Uint8 *p; /* Assuming the X/Y values are within the bounds of this surface... */ - if (likely - (likely((unsigned) x < (unsigned) surface->w) - && likely((unsigned) y < (unsigned) surface->h))) + if (likely(likely((unsigned)x < (unsigned)surface->w) && likely((unsigned)y < (unsigned)surface->h))) { // Set a pointer to the exact location in memory of the pixel p = (Uint8 *) (((Uint8 *) surface->pixels) + /* Start: beginning of RAM */ @@ -141,9 +133,9 @@ static Uint32 getpixel8(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel @@ -167,9 +159,9 @@ static Uint32 getpixel16(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel @@ -194,9 +186,9 @@ static Uint32 getpixel24(SDL_Surface * surface, int x, int y) Uint32 pixel; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel @@ -227,9 +219,9 @@ static Uint32 getpixel32(SDL_Surface * surface, int x, int y) Uint8 *p; /* get the X/Y values within the bounds of this surface */ - if (unlikely((unsigned) x > (unsigned) surface->w - 1u)) + if (unlikely((unsigned)x > (unsigned)surface->w - 1u)) x = (x < 0) ? 0 : surface->w - 1; - if (unlikely((unsigned) y > (unsigned) surface->h - 1u)) + if (unlikely((unsigned)y > (unsigned)surface->h - 1u)) y = (y < 0) ? 0 : surface->h - 1; /* Set a pointer to the exact location in memory of the pixel diff --git a/src/playsound.c b/src/playsound.c index d59726b86..b39ca9434 100644 --- a/src/playsound.c +++ b/src/playsound.c @@ -49,8 +49,7 @@ static int old_sound[4] = { -1, -1, -1, -1 }; * (low values, near the top of the window, are quieter), or * SNDDIST_NEAR for full volume */ -void playsound(SDL_Surface * screen, int chan, int s, int override, int x, - int y) +void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y) { #ifndef NOSOUND int left, dist; @@ -109,8 +108,7 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, left = (255 - dist) / 2; } #ifdef DEBUG - printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, - chan, left, (255 - dist) - left); + printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255 - dist) - left); fflush(stdout); #endif Mix_SetPanning(chan, left, (255 - dist) - left); diff --git a/src/playsound.h b/src/playsound.h index 63c9094fe..958a94c70 100644 --- a/src/playsound.h +++ b/src/playsound.h @@ -38,7 +38,6 @@ extern Mix_Chunk *sounds[NUM_SOUNDS]; extern int mute, use_sound, use_stereo; -void playsound(SDL_Surface * screen, int chan, int s, int override, int x, - int y); +void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y); #endif diff --git a/src/postscript_print.c b/src/postscript_print.c index f0246b63f..de698b7a2 100644 --- a/src/postscript_print.c +++ b/src/postscript_print.c @@ -68,18 +68,17 @@ static int f2int(float f) { - return ((int) f); + return ((int)f); } static int f2dec(float f) { - return (int) ((f - f2int(f)) * 100); + return (int)((f - f2int(f)) * 100); } /* Actually save the PostScript data to the file stream: */ int do_ps_save(FILE * fi, - const char *restrict const fname, SDL_Surface * surf, - const char *restrict pprsize, int is_pipe) + const char *restrict const fname, SDL_Surface * surf, const char *restrict pprsize, int is_pipe) { const struct paper *ppr; int img_w = surf->w; @@ -93,8 +92,7 @@ int do_ps_save(FILE * fi, Uint8 r, g, b; char buf[256]; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[surf->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[surf->format->BytesPerPixel]; int printed_img_w, printed_img_h; time_t t = time(NULL); int rotate; @@ -148,8 +146,7 @@ int do_ps_save(FILE * fi, ppr_h = paperpsheight(ppr); #ifdef DEBUG - printf("Paper is %d x %d (%.2f\" x %.2f\")\n", ppr_w, ppr_h, - (float) ppr_w / 72.0, (float) ppr_h / 72.0); + printf("Paper is %d x %d (%.2f\" x %.2f\")\n", ppr_w, ppr_h, (float)ppr_w / 72.0, (float)ppr_h / 72.0); #endif paperdone(); // FIXME: Should we do this at quit? -bjk 2007.06.25 @@ -157,8 +154,7 @@ int do_ps_save(FILE * fi, /* Determine whether it's best to rotate the image: */ - if ((ppr_w >= ppr_h && img_w >= img_h) - || (ppr_w <= ppr_h && img_w <= img_h)) + if ((ppr_w >= ppr_h && img_w >= img_h) || (ppr_w <= ppr_h && img_w <= img_h)) { rotate = 0; r_img_w = img_w; @@ -180,16 +176,13 @@ int do_ps_save(FILE * fi, /* Determine scale: */ - scale = - my_min(((float) (ppr_w - (MARGIN * 2)) / (float) r_img_w), - ((float) (ppr_h - (MARGIN * 2)) / (float) r_img_h)); + scale = my_min(((float)(ppr_w - (MARGIN * 2)) / (float)r_img_w), ((float)(ppr_h - (MARGIN * 2)) / (float)r_img_h)); printed_img_w = r_img_w * scale; printed_img_h = r_img_h * scale; #ifdef DEBUG - printf("Scaling image by %.2f (to %d x %d)\n", scale, printed_img_w, - printed_img_h); + printf("Scaling image by %.2f (to %d x %d)\n", scale, printed_img_w, printed_img_h); #endif @@ -215,8 +208,7 @@ int do_ps_save(FILE * fi, fprintf(fi, "%%%%Pages: 1\n"); - fprintf(fi, "%%%%BoundingBox: 0 0 %d %d\n", (int) (ppr_w + 0.5), - (int) (ppr_h + 0.5)); + fprintf(fi, "%%%%BoundingBox: 0 0 %d %d\n", (int)(ppr_w + 0.5), (int)(ppr_h + 0.5)); fprintf(fi, "%%%%EndComments\n"); @@ -235,23 +227,20 @@ int do_ps_save(FILE * fi, fprintf(fi, "%%%%Page: 1 1\n"); - fprintf(fi, "<< /PageSize [ %d %d ] /ImagingBBox null >> setpagedevice\n", - ppr_w, ppr_h); + fprintf(fi, "<< /PageSize [ %d %d ] /ImagingBBox null >> setpagedevice\n", ppr_w, ppr_h); fprintf(fi, "gsave\n"); /* 'translate' moves the user space origin to a new position with respect to the current page, leaving the orientation of the axes and the unit lengths unchanged. */ - fprintf(fi, "%d.%02d %d.%02d translate\n", f2int(tlate_x), f2dec(tlate_x), - f2int(tlate_y), f2dec(tlate_y)); + fprintf(fi, "%d.%02d %d.%02d translate\n", f2int(tlate_x), f2dec(tlate_x), f2int(tlate_y), f2dec(tlate_y)); /* 'scale' modifies the unit lengths independently along the current x and y axes, leaving the origin location and the orientation of the axes unchanged. */ fprintf(fi, "%d.%02d %d.%02d scale\n", - f2int(printed_img_w), f2dec(printed_img_w), f2int(printed_img_h), - f2dec(printed_img_h)); + f2int(printed_img_w), f2dec(printed_img_w), f2int(printed_img_h), f2dec(printed_img_h)); /* Rotate the image */ if (rotate) diff --git a/src/postscript_print.h b/src/postscript_print.h index 99708998c..8caf7d87b 100644 --- a/src/postscript_print.h +++ b/src/postscript_print.h @@ -79,8 +79,7 @@ #ifdef PRINTMETHOD_PS int do_ps_save(FILE * fi, - const char *restrict const fname, SDL_Surface * surf, - const char *restrict pprsize, int is_pipe); + const char *restrict const fname, SDL_Surface * surf, const char *restrict pprsize, int is_pipe); #endif diff --git a/src/progressbar.c b/src/progressbar.c index 461c9644a..9a7db5a1d 100644 --- a/src/progressbar.c +++ b/src/progressbar.c @@ -39,8 +39,7 @@ int progress_bar_disabled, prog_bar_ctr; * * @param screen Screen surface */ -void show_progress_bar_(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer) +void show_progress_bar_(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer) { SDL_Rect dest, src, r; int x; @@ -73,9 +72,7 @@ void show_progress_bar_(SDL_Surface * screen, SDL_Texture * texture, r.w = screen->w; r.h = 24; - SDL_UpdateTexture(texture, &r, - screen->pixels + ((screen->h - 24) * screen->pitch), - screen->pitch); + SDL_UpdateTexture(texture, &r, screen->pixels + ((screen->h - 24) * screen->pitch), screen->pitch); /* Docs says one should clear the renderer, even if this means a refresh of the whole thing. */ SDL_RenderClear(renderer); diff --git a/src/progressbar.h b/src/progressbar.h index 9061fef7a..52f99caeb 100644 --- a/src/progressbar.h +++ b/src/progressbar.h @@ -36,7 +36,6 @@ extern SDL_Surface *img_progress; extern int progress_bar_disabled, prog_bar_ctr; -void show_progress_bar_(SDL_Surface * screen, SDL_Texture * texture, - SDL_Renderer * renderer); +void show_progress_bar_(SDL_Surface * screen, SDL_Texture * texture, SDL_Renderer * renderer); #endif diff --git a/src/rgblinear.h b/src/rgblinear.h index 7bca5f64f..7fe31ec9e 100644 --- a/src/rgblinear.h +++ b/src/rgblinear.h @@ -305,8 +305,7 @@ static const unsigned char linear_to_sRGB_table[4096] = "\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd" "\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfd\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe" "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe" - "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; + "\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff" "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"; unsigned char linear_to_sRGB(float linear) FUNCTION; diff --git a/src/shapes.h b/src/shapes.h index 0a6565f03..e13f2f096 100644 --- a/src/shapes.h +++ b/src/shapes.h @@ -327,10 +327,8 @@ const char *const shape_tips[NUM_SHAPES] = { gettext_noop("A rectangle has four sides and four right angles."), // Description of a circle - gettext_noop - ("A circle is a curve where all points have the same distance from the center."), - gettext_noop - ("A circle is a curve where all points have the same distance from the center."), + gettext_noop("A circle is a curve where all points have the same distance from the center."), + gettext_noop("A circle is a curve where all points have the same distance from the center."), // Description of an ellipse gettext_noop("An ellipse is a stretched circle."), @@ -357,11 +355,9 @@ const char *const shape_tips[NUM_SHAPES] = { gettext_noop("An octagon has eight equal sides."), // Description of a rhombus - gettext_noop - ("A rhombus has four equal sides, and opposite sides are parallel."), - gettext_noop - ("A rhombus has four equal sides, and opposite sides are parallel."), - + gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."), + gettext_noop("A rhombus has four equal sides, and opposite sides are parallel."), + // Description of triangle star (3 points star) gettext_noop("A star with 3 points."), gettext_noop("A star with 3 points."), @@ -435,8 +431,7 @@ enum const char *const shape_tool_tips[NUM_SHAPE_COMPLEXITIES] = { gettext_noop ("Pick a shape. Click to start drawing, drag, and let go when it is the size and shape you want. Move around to rotate it, and click again to draw it."), - gettext_noop - ("Pick a shape. Click to start drawing, drag, and let go when it is the size and shape you want.") + gettext_noop("Pick a shape. Click to start drawing, drag, and let go when it is the size and shape you want.") }; /* Strings shown when switching between "from center" diff --git a/src/test-png.c b/src/test-png.c index 3acbaee07..98fe46b16 100644 --- a/src/test-png.c +++ b/src/test-png.c @@ -57,9 +57,7 @@ int main(int argc, char *argv[]) /* Open each PNG image!... */ for (i = 1; i < argc; i++) { - printf - ("%5d ------------------------------------------------------------------\n", - i); + printf("%5d ------------------------------------------------------------------\n", i); printf("%s\n", argv[i]); fflush(stdout); @@ -134,8 +132,7 @@ int main(int argc, char *argv[]) } /* Fill alpha channel if there is none */ - if (ctype == PNG_COLOR_TYPE_RGB || - ctype == PNG_COLOR_TYPE_GRAY || ctype == PNG_COLOR_TYPE_PALETTE) + if (ctype == PNG_COLOR_TYPE_RGB || ctype == PNG_COLOR_TYPE_GRAY || ctype == PNG_COLOR_TYPE_PALETTE) { png_set_filler(png, 0xFF, PNG_FILLER_AFTER); } @@ -163,8 +160,7 @@ int main(int argc, char *argv[]) rows[y] = (png_byte *) malloc(png_get_rowbytes(png, info)); if (!rows[y]) { - fprintf(stderr, - "Failed to malloc() space for image data row #%d!\n", y); + fprintf(stderr, "Failed to malloc() space for image data row #%d!\n", y); exit(1); } } diff --git a/src/tuxpaint.c b/src/tuxpaint.c index e8b970248..ba1715199 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -151,26 +151,30 @@ static scaleparams scaletable[] = { {48, 1}, /* 48 */ }; -enum { - STARTER_TEMPLATE_SCALE_MODE_NONE, /* smear or apply background color */ - STARTER_TEMPLATE_SCALE_MODE_HORIZ, /* allow zooming in (cropping left/right) if image is wider than the canvas */ - STARTER_TEMPLATE_SCALE_MODE_VERT, /* allow zooming in (cropping top/bottom) if image is taller than the canvas */ - STARTER_TEMPLATE_SCALE_MODE_BOTH /* allow zooming in (cropping anything) if canvas is smaller in either/both dimensions */ +enum +{ + STARTER_TEMPLATE_SCALE_MODE_NONE, /* smear or apply background color */ + STARTER_TEMPLATE_SCALE_MODE_HORIZ, /* allow zooming in (cropping left/right) if image is wider than the canvas */ + STARTER_TEMPLATE_SCALE_MODE_VERT, /* allow zooming in (cropping top/bottom) if image is taller than the canvas */ + STARTER_TEMPLATE_SCALE_MODE_BOTH /* allow zooming in (cropping anything) if canvas is smaller in either/both dimensions */ }; -enum { +enum +{ STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER, STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT, STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT }; -enum { +enum +{ STARTER_TEMPLATE_GRAVITY_VERT_CENTER, STARTER_TEMPLATE_GRAVITY_VERT_TOP, STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM }; -typedef struct starter_template_options_s { +typedef struct starter_template_options_s +{ int scale_mode; int h_gravity; int v_gravity; @@ -251,7 +255,7 @@ char *strcasestr(const char *haystack, const char *needle) result = strstr(uphaystack, upneedle); if (result != NULL) - return (result - uphaystack + (char *) haystack); + return (result - uphaystack + (char *)haystack); else return NULL; } @@ -391,6 +395,7 @@ extern int win32_trash(const char *path); int iswprint(wchar_t wc) { WORD t; + GetStringTypeW(CT_CTYPE1, &wc, 1, &t); return (t & C1_DEFINED) && !(t & C1_CNTRL); } @@ -597,8 +602,7 @@ static void reposition_onscreen_keyboard(int y); int calc_magic_control_rows(void); -static void reset_stamps(int *stamp_xored_rt, int *stamp_place_x, - int *stamp_place_y, int *stamp_tool_mode); +static void reset_stamps(int *stamp_xored_rt, int *stamp_place_x, int *stamp_place_y, int *stamp_tool_mode); /* EP added #ifndef __APPLE__ because macros are buggy (shifted by 1 byte), plus the function exists in SDL */ #ifndef __APPLE__ @@ -758,7 +762,7 @@ static char **color_names; static void debug(const char *const str) { #ifndef DEBUG - (void) str; + (void)str; #else fprintf(stderr, "DEBUG: %s\n", str); fflush(stderr); @@ -852,16 +856,13 @@ static void set_max_buttonscale(void) float max_w, max_h; /* WINDOW_WIDTH / original size of tools columns + 9 buttons + tooloption columns */ - max_w = - (float) WINDOW_WIDTH / (gd_tools.cols * 48 + 9 * 48 + - gd_toolopt.cols * 48); + max_w = (float)WINDOW_WIDTH / (gd_tools.cols * 48 + 9 * 48 + gd_toolopt.cols * 48); /* WINDOW_HEIGHT / original size of r_ttools.h + 5 buttons + colors rows + tux area */ - max_h = (float) WINDOW_HEIGHT / (40 + 5 * 48 + gd_colors.rows * 48 + 56); + max_h = (float)WINDOW_HEIGHT / (40 + 5 * 48 + gd_colors.rows * 48 + 56); button_scale = min(max_w, max_h); - fprintf(stderr, "Will use a button size of %d\n", - (int) (button_scale * ORIGINAL_BUTTON_SIZE)); + fprintf(stderr, "Will use a button size of %d\n", (int)(button_scale * ORIGINAL_BUTTON_SIZE)); } /** @@ -913,9 +914,7 @@ static void setup_normal_screen_layout(void) r_tuxarea.w = WINDOW_WIDTH; /* need 56 minimum for the Tux area */ - buttons_tall = - (WINDOW_HEIGHT - r_ttoolopt.h - 56 * button_scale - - r_colors.h) / button_h; + buttons_tall = (WINDOW_HEIGHT - r_ttoolopt.h - 56 * button_scale - r_colors.h) / button_h; if (buttons_tall < 5) { fprintf(stderr, @@ -1086,8 +1085,7 @@ static void SDL_Flip(SDL_Surface * screen) SDL_RenderPresent(renderer); } -static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, - Sint32 h) +static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h) { SDL_Rect r; @@ -1096,8 +1094,7 @@ static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, r.w = w; r.h = h; - SDL_UpdateTexture(texture, &r, screen->pixels + (y * screen->pitch + x * 4), - screen->pitch); + SDL_UpdateTexture(texture, &r, screen->pixels + (y * screen->pitch + x * 4), screen->pitch); // Docs says one must clear the renderer, even if this means a refresh of the whole thing. SDL_RenderClear(renderer); @@ -1192,8 +1189,7 @@ static void update_screen_rect(SDL_Rect * r) static int hit_test(const SDL_Rect * const r, unsigned x, unsigned y) { /* note the use of unsigned math: no need to check for negative */ - return (x - (unsigned) r->x < (unsigned) r->w) - && (y - (unsigned) r->y < (unsigned) r->h); + return (x - (unsigned)r->x < (unsigned)r->w) && (y - (unsigned)r->y < (unsigned)r->h); } #define HIT(r) hit_test(&(r), event.button.x, event.button.y) @@ -1208,8 +1204,7 @@ static int hit_test(const SDL_Rect * const r, unsigned x, unsigned y) * @param gd The grid of items * @returns The item clicked, or -1 if click was outside the grid. */ -static int grid_hit_gd(const SDL_Rect * const r, unsigned x, unsigned y, - grid_dims * gd) +static int grid_hit_gd(const SDL_Rect * const r, unsigned x, unsigned y, grid_dims * gd) { unsigned item_w = r->w / gd->cols; unsigned item_h = r->h / gd->rows; @@ -1217,7 +1212,7 @@ static int grid_hit_gd(const SDL_Rect * const r, unsigned x, unsigned y, unsigned row = (y - r->y) / item_h; DEBUG_PRINTF("%d,%d resolves to %d,%d in a %dx%d grid, index is %d\n", x, y, col, - row, gd->cols, gd->rows, col + row * gd->cols); + row, gd->cols, gd->rows, col + row * gd->cols); if (col >= gd->cols || row >= gd->rows) return -1; return col + row * gd->cols; @@ -1402,8 +1397,7 @@ static int button_down; static int scrolling_selector, scrolling_tool, scrolling_dialog; static int promptless_save = SAVE_OVER_UNSET; -static int _promptless_save_over, _promptless_save_over_ask, - _promptless_save_over_new; +static int _promptless_save_over, _promptless_save_over_ask, _promptless_save_over_new; static int disable_quit; static int noshortcuts; @@ -1497,12 +1491,10 @@ static unsigned select_text_size; static int coming_from_undo_or_redo = FALSE; -static void add_label_node(int, int, Uint16, Uint16, - SDL_Surface * label_node_surface); +static void add_label_node(int, int, Uint16, Uint16, SDL_Surface * label_node_surface); static void load_info_about_label_surface(FILE * lfi); -static struct label_node *search_label_list(struct label_node **, Uint16, - Uint16, int hover); +static struct label_node *search_label_list(struct label_node **, Uint16, Uint16, int hover); static void highlight_label_nodes(void); static void cycle_highlighted_label_node(void); static int are_labels(void); @@ -1518,28 +1510,22 @@ static void derender_node(struct label_node **); static void delete_label_list(struct label_node **); -static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, - SDL_Surface * dest_surf, SDL_Rect * dest_rect); +static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, SDL_Surface * dest_surf, SDL_Rect * dest_rect); static void set_label_fonts(void); static void tmp_apply_uncommited_text(void); static void undo_tmp_applied_text(void); -static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, - int *val_y); +static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, int *val_y); static void handle_joyhatmotion(SDL_Event event, int oldpos_x, int oldpos_y, - int *valhat_x, int *valhat_y, - int *hat_motioner, Uint32 * old_hat_ticks); + int *valhat_x, int *valhat_y, int *hat_motioner, Uint32 * old_hat_ticks); static void handle_joyballmotion(SDL_Event event, int oldpos_x, int oldpos_y); -static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, - int oldpos_y); +static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, int oldpos_y); static void handle_motioners(int oldpos_x, int oldpos_y, int motioner, - int hatmotioner, int old_hat_ticks, int val_x, - int val_y, int valhat_x, int valhat_y); + int hatmotioner, int old_hat_ticks, int val_x, int val_y, int valhat_x, int valhat_y); -static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, - int oldpos_y, SDL_Rect real_r_tools); +static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools); #ifdef __ANDROID__ static void start_motion_convert(SDL_Event event); @@ -1548,6 +1534,7 @@ static void stop_motion_convert(SDL_Event event); #endif char *get_xdg_user_dir(const char *dir_type, const char *fallback); + #ifdef WIN32 extern char *GetUserImageDir(void); #endif @@ -1567,20 +1554,17 @@ typedef struct magic_funcs_s SDL_Surface *(*get_icon)(magic_api *, int); char *(*get_description)(magic_api *, int, int); int (*requires_colors)(magic_api *, int); - Uint8 (*accepted_sizes)(magic_api *, int, int); - Uint8 (*default_size)(magic_api *, int, int); + Uint8(*accepted_sizes) (magic_api *, int, int); + Uint8(*default_size) (magic_api *, int, int); int (*modes)(magic_api *, int); void (*set_color)(magic_api *, int, SDL_Surface *, SDL_Surface *, Uint8, Uint8, Uint8, SDL_Rect *); void (*set_size)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, Uint8, SDL_Rect *); int (*init)(magic_api *, Uint32); - Uint32(*api_version) (void); + Uint32(*api_version) (void); void (*shutdown)(magic_api *); - void (*click)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, - SDL_Rect *); - void (*drag)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, - int, SDL_Rect *); - void (*release)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, - SDL_Rect *); + void (*click)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); + void (*drag)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *); + void (*release)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); void (*switchin)(magic_api *, int, int, SDL_Surface *, SDL_Surface *); void (*switchout)(magic_api *, int, int, SDL_Surface *, SDL_Surface *); } magic_funcs_t; @@ -1673,8 +1657,7 @@ static int have_to_rec_label_node; static int have_to_rec_label_node_back; static SDL_Surface *img_title, *img_title_credits, *img_title_tuxpaint; static SDL_Surface *img_btn_up, *img_btn_down, *img_btn_off, *img_btn_hold; -static SDL_Surface *img_btnsm_up, *img_btnsm_off, *img_btnsm_down, - *img_btnsm_hold; +static SDL_Surface *img_btnsm_up, *img_btnsm_off, *img_btnsm_down, *img_btnsm_hold; static SDL_Surface *img_btn_nav, *img_btnsm_nav; static SDL_Surface *img_brush_anim, *img_brush_dir; static SDL_Surface *img_prev, *img_next; @@ -1683,10 +1666,8 @@ static SDL_Surface *img_dead40x40; static SDL_Surface *img_black, *img_grey; static SDL_Surface *img_yes, *img_no; static SDL_Surface *img_sfx, *img_speak; -static SDL_Surface *img_open, *img_erase, *img_back, *img_trash, - *img_pict_export; -static SDL_Surface *img_slideshow, *img_play, *img_gif_export, - *img_select_digits; +static SDL_Surface *img_open, *img_erase, *img_back, *img_trash, *img_pict_export; +static SDL_Surface *img_slideshow, *img_play, *img_gif_export, *img_select_digits; static SDL_Surface *img_printer, *img_printer_wait; static SDL_Surface *img_save_over, *img_popup_arrow; static SDL_Surface *img_cursor_up, *img_cursor_down; @@ -1698,24 +1679,19 @@ static SDL_Surface *img_magic_paint, *img_magic_fullscreen; static SDL_Surface *img_shapes_corner, *img_shapes_center; static SDL_Surface *img_bold, *img_italic; static SDL_Surface *img_label_select, *img_label_apply; -static SDL_Surface *img_color_picker, *img_color_picker_thumb, - *img_color_picker_val; +static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_color_picker_val; static SDL_Surface *img_paintwell, *img_color_sel, *img_color_mix; static SDL_Surface *img_color_grab; static int color_picker_x, color_picker_y, color_picker_v; static int color_mixer_reset; -static SDL_Surface *img_title_on, *img_title_off, *img_title_large_on, - *img_title_large_off; +static SDL_Surface *img_title_on, *img_title_off, *img_title_large_on, *img_title_large_off; static SDL_Surface *img_title_names[NUM_TITLES]; static SDL_Surface *img_tools[NUM_TOOLS], *img_tool_names[NUM_TOOLS]; -static SDL_Surface *img_oskdel, *img_osktab, *img_oskenter, *img_oskcapslock, - *img_oskshift; -static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, - int keep_aspect); -static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, - int keep_aspect, int keep_alpha); +static SDL_Surface *img_oskdel, *img_osktab, *img_oskenter, *img_oskcapslock, *img_oskshift; +static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, int keep_aspect); +static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep_aspect, int keep_alpha); #ifndef NO_BILINEAR static SDL_Surface *zoom(SDL_Surface * src, int new_x, int new_y); @@ -1730,8 +1706,7 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_x, int new_y); * @param color The color to draw it in * @return A new surface, containing the rendered text */ -static SDL_Surface *render_text(TuxPaint_Font * restrict font, - const char *restrict str, SDL_Color color) +static SDL_Surface *render_text(TuxPaint_Font * restrict font, const char *restrict str, SDL_Color color) { SDL_Surface *ret = NULL; int height; @@ -1825,9 +1800,7 @@ static Uint16 *wcstou16(const wchar_t *str) * @param color The color to draw it in * @return A new surface, containing the rendered text */ -static SDL_Surface *render_text_w(TuxPaint_Font * restrict font, - const wchar_t *restrict str, - SDL_Color color) +static SDL_Surface *render_text_w(TuxPaint_Font * restrict font, const wchar_t *restrict str, SDL_Color color) { SDL_Surface *ret = NULL; int height; @@ -1849,7 +1822,7 @@ static SDL_Surface *render_text_w(TuxPaint_Font * restrict font, /* Convert from 16-bit UNICODE to UTF-8 encoded for SDL_Pango: */ utfstr_max = (sizeof(char) * 4 * (wcslen(str) + 1)); - utfstr = (char *) malloc(utfstr_max); + utfstr = (char *)malloc(utfstr_max); wcstombs(utfstr, str, utfstr_max); @@ -1972,8 +1945,7 @@ static SDL_Surface *img_shapes[NUM_SHAPES], *img_shape_names[NUM_SHAPES]; static SDL_Surface *img_fills[NUM_FILLS], *img_fill_names[NUM_FILLS]; static SDL_Surface *img_openlabels_open, *img_openlabels_erase, *img_openlabels_slideshow, *img_openlabels_back, *img_openlabels_play, - *img_openlabels_gif_export, *img_openlabels_pict_export, - *img_openlabels_next, *img_mixerlabel_clear; + *img_openlabels_gif_export, *img_openlabels_pict_export, *img_openlabels_next, *img_mixerlabel_clear; static SDL_Surface *img_tux[NUM_TIP_TUX]; @@ -2003,8 +1975,7 @@ enum static SDL_Surface *img_cur_brush; static int img_cur_brush_frame_w, img_cur_brush_w, img_cur_brush_h, - img_cur_brush_frames, img_cur_brush_directional, img_cur_brush_rotate, - img_cur_brush_spacing; + img_cur_brush_frames, img_cur_brush_directional, img_cur_brush_rotate, img_cur_brush_spacing; static int brush_counter, brush_frame; #define NUM_ERASERS 16 /* How many sizes of erasers @@ -2075,8 +2046,7 @@ typedef enum #define NUM_EDGES 4 -static SDL_Event scrolltimer_selector_event, scrolltimer_tool_event, - scrolltimer_dialog_event; +static SDL_Event scrolltimer_selector_event, scrolltimer_tool_event, scrolltimer_dialog_event; int non_left_click_count = 0; @@ -2093,8 +2063,7 @@ SDL_Joystick *joystick; static void mainloop(void); static void brush_draw(int x1, int y1, int x2, int y2, int update); -static void blit_brush(int x, int y, int direction, double rotation, int *w, - int *h); +static void blit_brush(int x, int y, int direction, double rotation, int *w, int *h); static void stamp_draw(int x, int y, int stamp_angle_rotation); static void rec_undo_buffer(void); @@ -2103,8 +2072,7 @@ void show_usage(int exitcode); static char *progname; static SDL_Cursor *get_cursor(unsigned char *bits, unsigned char *mask_bits, - unsigned int w, unsigned int h, unsigned int x, - unsigned int y); + unsigned int w, unsigned int h, unsigned int x, unsigned int y); static void seticon(void); static SDL_Surface *loadimage(const char *const fname); static SDL_Surface *do_loadimage(const char *const fname, int abort_on_error); @@ -2157,16 +2125,12 @@ static void reset_avail_tools(void); static int compare_dirent2s(struct dirent2 *f1, struct dirent2 *f2); static int compare_dirent2s_invert(struct dirent2 *f1, struct dirent2 *f2); static void redraw_tux_text(void); -static void draw_tux_text(int which_tux, const char *const str, - int want_right_to_left); -static void draw_tux_text_ex(int which_tux, const char *const str, - int want_right_to_left, Uint8 locale_text); +static void draw_tux_text(int which_tux, const char *const str, int want_right_to_left); +static void draw_tux_text_ex(int which_tux, const char *const str, int want_right_to_left, Uint8 locale_text); static void draw_cur_tool_tip(void); -static void wordwrap_text(const char *const str, SDL_Color color, int left, - int top, int right, int want_right_to_left); +static void wordwrap_text(const char *const str, SDL_Color color, int left, int top, int right, int want_right_to_left); static void wordwrap_text_ex(const char *const str, SDL_Color color, int left, - int top, int right, int want_right_to_left, - Uint8 locale_text); + int top, int right, int want_right_to_left, Uint8 locale_text); static char *loaddesc(const char *const fname, Uint8 * locale_text); static double loadinfo(const char *const fname, stamp_type * inf); @@ -2181,25 +2145,20 @@ static void save_current(void); static int do_prompt_image_flash(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, - int animate, int ox, int oy); + SDL_Surface * img2, SDL_Surface * img3, int animate, int ox, int oy); static int do_prompt_image_flash_snd(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, SDL_Surface * img2, - SDL_Surface * img3, int animate, int snd, - int ox, int oy); + SDL_Surface * img3, int animate, int snd, int ox, int oy); static int do_prompt_image(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, int ox, - int oy); + SDL_Surface * img2, SDL_Surface * img3, int ox, int oy); static int do_prompt_image_snd(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, - int snd, int ox, int oy); -static int do_prompt(const char *const text, const char *const btn_yes, - const char *const btn_no, int ox, int oy); + SDL_Surface * img2, SDL_Surface * img3, int snd, int ox, int oy); +static int do_prompt(const char *const text, const char *const btn_yes, const char *const btn_no, int ox, int oy); static int do_prompt_snd(const char *const text, const char *const btn_yes, const char *const btn_no, int snd, int ox, int oy); static void cleanup(void); @@ -2214,42 +2173,34 @@ static int brush_rotation(int ctr_x, int ctr_y, int ox, int oy); static int stamp_will_rotate(int ctr_x, int ctr_y, int ox, int oy); static int stamp_rotation(int ctr_x, int ctr_y, int ox, int oy); static int do_save(int tool, int dont_show_success_results, int autosave); -static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, - int embed); +static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, int embed); static void load_embedded_data(char *fname, SDL_Surface * org_surf); static int chunk_is_valid(const char *chunk_name, png_unknown_chunk unknown); Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr, - png_infop info_ptr, const char *chunk_name, - png_unknown_chunk unknown, int *unc_size); + png_infop info_ptr, const char *chunk_name, png_unknown_chunk unknown, int *unc_size); static void get_new_file_id(void); static int do_quit(int tool); static int do_open(void); static int do_new_dialog(void); static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, - int *d_places, char * *d_names, - char * *d_exts, int *white_in_palette); + int *d_places, char * *d_names, char * *d_exts, int *white_in_palette); static int do_color_picker(int prev_color); static void draw_color_picker_crosshairs(int color_picker_left, - int color_picker_top, - int color_picker_val_left, - int color_picker_val_top); + int color_picker_top, int color_picker_val_left, int color_picker_val_top); static void set_color_picker_crosshair_size(void); static void draw_color_picker_values(int l, int t); static void draw_color_grab_btn(SDL_Rect dest, int c); static void draw_color_picker_palette_and_values(int color_picker_left, int color_picker_top, - int color_picker_val_left, - int color_picker_val_top); + int color_picker_val_left, int color_picker_val_top); static void render_color_picker_palette(void); static int do_color_sel(int temp_mode); static int do_color_mix(void); static void draw_color_mixer_blank_example(void); -static void calc_color_mixer_average(float *out_h, float *out_s, - float *out_v); +static void calc_color_mixer_average(float *out_h, float *out_s, float *out_v); static void draw_color_mixer_tooltip(void); static void draw_color_mix_undo_redo(void); -static void render_color_button(int the_color, SDL_Surface * decoration, - SDL_Surface * icon); +static void render_color_button(int the_color, SDL_Surface * decoration, SDL_Surface * icon); static void handle_color_changed(void); static void magic_set_color(void); static void magic_set_size(void); @@ -2257,21 +2208,17 @@ static void magic_set_size(void); static void do_quick_eraser(void); static int do_slideshow(void); -static void play_slideshow(int *selected, int num_selected, char *dirname, - char **d_names, char **d_exts, int speed); +static void play_slideshow(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed); static void draw_selection_digits(int right, int bottom, int n); -static int export_gif(int *selected, int num_selected, char *dirname, - char **d_names, char **d_exts, int speed); +static int export_gif(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed); int export_gif_monitor_events(void); static int export_pict(char *fname); static char *get_export_filepath(const char *ext); static void wait_for_sfx(void); -static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, - float *v); -static void hsvtorgb(float h, float s, float v, Uint8 * r8, Uint8 * g8, - Uint8 * b8); +static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, float *v); +static void hsvtorgb(float h, float s, float v, Uint8 * r8, Uint8 * g8, Uint8 * b8); static SDL_Surface *flip_surface(SDL_Surface * s); static SDL_Surface *mirror_surface(SDL_Surface * s); @@ -2284,28 +2231,25 @@ static char *uppercase(const char *restrict const str); static wchar_t *uppercase_w(const wchar_t *restrict const str); static char *textdir(const char *const str); static SDL_Surface *do_render_button_label(const char *const label); + #if 0 -static SDL_Surface * crop_surface(SDL_Surface * surf); +static SDL_Surface *crop_surface(SDL_Surface * surf); #endif static void create_button_labels(void); static Uint32 scrolltimer_selector_callback(Uint32 interval, void *param); static Uint32 scrolltimer_tool_callback(Uint32 interval, void *param); static Uint32 scrolltimer_dialog_callback(Uint32 interval, void *param); static Uint32 drawtext_callback(Uint32 interval, void *param); -static void control_drawtext_timer(Uint32 interval, const char *const text, - Uint8 locale_text); +static void control_drawtext_timer(Uint32 interval, const char *const text, Uint8 locale_text); static const char *great_str(void); static void draw_image_title(int t, SDL_Rect dest); -static void handle_keymouse(SDLKey key, Uint32 updown, int steps, - SDL_Rect * area1, SDL_Rect * area2); -static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, - SDL_Rect real_r_tools); +static void handle_keymouse(SDLKey key, Uint32 updown, int steps, SDL_Rect * area1, SDL_Rect * area2); +static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Rect real_r_tools); static void handle_active(SDL_Event * event); /*static char *replace_tilde(const char* const path);*/ #ifdef NO_SDLPANGO -static void anti_carriage_return(int left, int right, int cur_top, - int new_top, int cur_bot, int line_width); +static void anti_carriage_return(int left, int right, int cur_top, int new_top, int cur_bot, int line_width); #endif static void load_starter_id(char *saved_id, FILE * fil); static void load_starter(char *img_id); @@ -2325,10 +2269,7 @@ static void magic_stopsound(void); static void magic_line_func(void *mapi, int which, SDL_Surface * canvas, SDL_Surface * last, int x1, int y1, int x2, - int y2, int step, void (*cb)(void *, int, - SDL_Surface *, - SDL_Surface *, int, - int)); + int y2, int step, void (*cb)(void *, int, SDL_Surface *, SDL_Surface *, int, int)); static Uint8 magic_linear_to_sRGB(float lin); static float magic_sRGB_to_linear(Uint8 srgb); @@ -2351,8 +2292,7 @@ static SDL_Surface *load_kpx(const char *file); #ifndef NOSVG static SDL_Surface *load_svg(const char *file); -static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, - unsigned int max_w, unsigned int max_h); +static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h); #endif static SDL_Surface *myIMG_Load_RWops(const char *file); static SDL_Surface *myIMG_Load(const char *file); @@ -2402,6 +2342,7 @@ static void do_wait(int counter) { SDL_Event event; int done; + #ifdef ANNIVERSARY int i; SDL_Surface *back_surf; @@ -2421,9 +2362,7 @@ static void do_wait(int counter) confetti[i].xm = (rand() % 9) - 4; confetti[i].ym = (rand() % 4); confetti[i].ymm = ((rand() % 10) / 20) + 0.1; - confetti[i].color = SDL_MapRGB(screen->format, - (rand() % 128) + 96, - (rand() % 128) + 96, (rand() % 128) + 96); + confetti[i].color = SDL_MapRGB(screen->format, (rand() % 128) + 96, (rand() % 128) + 96, (rand() % 128) + 96); } back_surf = SDL_DisplayFormat(screen); @@ -2448,8 +2387,7 @@ static void do_wait(int counter) { done = 1; } - else if (event.type == SDL_MOUSEBUTTONDOWN - && valid_click(event.button.button)) + else if (event.type == SDL_MOUSEBUTTONDOWN && valid_click(event.button.button)) { done = 1; } @@ -2581,6 +2519,7 @@ enum STAMP_TOOL_MODE_PLACE, STAMP_TOOL_MODE_ROTATE }; + #define STAMP_XOR_LINE_UNSET INT_MIN on_screen_keyboard *new_kbd; SDL_Rect kbd_rect; @@ -2592,8 +2531,7 @@ SDL_Rect kbd_rect; #endif int brushflag, xnew, ynew, eraflag, lineflag, magicflag, keybd_flag, - keybd_position, keyglobal, initial_y, gen_key_flag, ide, activeflag, old_x, - old_y; + keybd_position, keyglobal, initial_y, gen_key_flag, ide, activeflag, old_x, old_y; int cur_thing; SDL_TimerID scrolltimer_dialog = TIMERID_NONE; /* Used by Open, Open->Slideshow, and New dialogs */ Uint32 TP_SDL_MOUSEBUTTONSCROLL; @@ -2622,6 +2560,7 @@ static void mainloop(void) int stamp_place_x = 0; int stamp_place_y = 0; int stamp_tool_mode = STAMP_TOOL_MODE_PLACE; + #ifdef EXPERIMENT_STAMP_ROTATION_LINE int stamp_xor_line_old_x = STAMP_XOR_LINE_UNSET; int stamp_xor_line_old_y = STAMP_XOR_LINE_UNSET; @@ -2634,13 +2573,11 @@ static void mainloop(void) #endif TP_SDL_MOUSEBUTTONSCROLL = SDL_RegisterEvents(1); - SDL_TimerID scrolltimer_selector = TIMERID_NONE, scrolltimer_tool = - TIMERID_NONE; + SDL_TimerID scrolltimer_selector = TIMERID_NONE, scrolltimer_tool = TIMERID_NONE; SDL_Event event; SDLKey key; SDLMod mod; - Uint32 last_cursor_blink, cur_cursor_blink, pre_event_time, - current_event_time; + Uint32 last_cursor_blink, cur_cursor_blink, pre_event_time, current_event_time; SDL_Rect update_rect; SDL_Rect real_r_tools = r_tools; @@ -2707,17 +2644,15 @@ static void mainloop(void) /* To avoid getting stuck in a 'catching up with mouse motion' interface lock-up */ /* FIXME: Another thing we could do here is peek into events, and 'skip' to the last motion...? Or something... -bjk 2011.04.26 */ - if (current_event_time > pre_event_time + 500 - && event.type == SDL_MOUSEMOTION) + if (current_event_time > pre_event_time + 500 && event.type == SDL_MOUSEMOTION) { - if (cur_tool == TOOL_STAMP - && stamp_tool_mode == STAMP_TOOL_MODE_ROTATE) + if (cur_tool == TOOL_STAMP && stamp_tool_mode == STAMP_TOOL_MODE_ROTATE) /* Discarding old stamp XORs, don't need to keep any outdated mouse motion event */ { - int rest = - SDL_PeepEvents(NULL, 1000, SDL_PEEKEVENT, SDL_MOUSEMOTION, - SDL_MOUSEMOTION); - int i; + int rest = SDL_PeepEvents(NULL, 1000, SDL_PEEKEVENT, SDL_MOUSEMOTION, + SDL_MOUSEMOTION); + int i; + for (i = 0; i < rest; i++) { SDL_PollEvent(&event); @@ -2768,8 +2703,7 @@ static void mainloop(void) else if (event.type == SDL_APP_DIDENTERFOREGROUND) { /* Discard the temp file saved before as the user takes again control */ - snprintf(tmp, sizeof(tmp), "saved/%s%s", AUTOSAVED_NAME, - FNAME_EXTENSION); + snprintf(tmp, sizeof(tmp), "saved/%s%s", AUTOSAVED_NAME, FNAME_EXTENSION); fname = get_fname(tmp, DIR_SAVE); fi = fopen(fname, "wb"); if (fi != NULL) @@ -2787,8 +2721,7 @@ static void mainloop(void) if (mouseaccessibility && emulate_button_pressed && ((cur_tool == TOOL_SHAPES && shape_tool_mode != SHAPE_TOOL_MODE_DONE) - || cur_tool == TOOL_LINES) - && event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) + || cur_tool == TOOL_LINES) && event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) /* event.active.state & (SDL_APPINPUTFOCUS|SDL_APPACTIVE) && event.active.gain == 0) */ { @@ -2814,13 +2747,13 @@ static void mainloop(void) /* FIXME: debug junk */ fprintf(stderr, "key 0x%04x mod 0x%04x character 0x%04x %d <%c> is %sprintable, key_down 0x%x\n", - (unsigned) key, - (unsigned) mod, - (unsigned) event.text.text, - (int) event.text.text, + (unsigned)key, + (unsigned)mod, + (unsigned)event.text.text, + (int)event.text.text, (key_unicode > ' ' - && key_unicode < 127) ? (char) event.text.text : ' ', - iswprint(key_unicode) ? "" : "not ", (unsigned) key_down); + && key_unicode < 127) ? (char)event.text.text : ' ', + iswprint(key_unicode) ? "" : "not ", (unsigned)key_down); #endif if (cur_tool == TOOL_STAMP) @@ -2847,8 +2780,7 @@ static void mainloop(void) if (!done) { magic_switchin(canvas); - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) { @@ -2888,8 +2820,7 @@ static void mainloop(void) } #endif } - else if ((key == SDLK_ESCAPE || key == SDLK_AC_BACK) - && (mod & KMOD_SHIFT) && (mod & KMOD_CTRL)) + else if ((key == SDLK_ESCAPE || key == SDLK_AC_BACK) && (mod & KMOD_SHIFT) && (mod & KMOD_CTRL)) { magic_switchout(canvas); done = do_quit(cur_tool); @@ -2905,7 +2836,8 @@ static void mainloop(void) magic_switchin(canvas); } #endif - else if (key == SDLK_z && (mod & KMOD_CTRL) && !noshortcuts && !button_down && !emulate_button_pressed && stamp_tool_mode != STAMP_TOOL_MODE_ROTATE && shape_tool_mode != SHAPE_TOOL_MODE_ROTATE) + else if (key == SDLK_z && (mod & KMOD_CTRL) && !noshortcuts && !button_down && !emulate_button_pressed + && stamp_tool_mode != STAMP_TOOL_MODE_ROTATE && shape_tool_mode != SHAPE_TOOL_MODE_ROTATE) { /* Ctrl-Z - Undo */ /* (As long as we're not in the middle of something!!!) */ @@ -2935,8 +2867,7 @@ static void mainloop(void) } } if (cur_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); if (cur_undo == newest_undo) { @@ -2959,8 +2890,7 @@ static void mainloop(void) if (tool_avail[TOOL_REDO]) { if (cur_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); hide_blinking_cursor(); do_redo(); update_screen_rect(&r_tools); @@ -2975,8 +2905,7 @@ static void mainloop(void) magic_switchout(canvas); if (cur_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); disable_avail_tools(); draw_toolbar(); @@ -3036,8 +2965,7 @@ static void mainloop(void) magic_switchout(canvas); if (cur_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); hide_blinking_cursor(); shape_tool_mode = SHAPE_TOOL_MODE_DONE; @@ -3100,10 +3028,8 @@ static void mainloop(void) hide_blinking_cursor(); /* Only reset stamp XORs if there will be prompt */ - if (cur_tool == TOOL_STAMP && promptless_save == SAVE_OVER_PROMPT - && file_id[0] != '\0') - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + if (cur_tool == TOOL_STAMP && promptless_save == SAVE_OVER_PROMPT && file_id[0] != '\0') + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); if (do_save(cur_tool, 0, 0)) { @@ -3132,8 +3058,7 @@ static void mainloop(void) magic_switchin(canvas); } #ifdef __APPLE__ - else if (key == SDLK_p && (mod & KMOD_CTRL) && (mod & KMOD_SHIFT) - && !noshortcuts) + else if (key == SDLK_p && (mod & KMOD_CTRL) && (mod & KMOD_SHIFT) && !noshortcuts) { /* Ctrl-Shft-P - Page Setup */ if (!disable_print) @@ -3148,8 +3073,7 @@ static void mainloop(void) { magic_switchout(canvas); if (cur_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); /* If they haven't hit [Enter], but clicked 'Print', add their text now -bjk 2007.10.25 */ @@ -3182,17 +3106,13 @@ static void mainloop(void) (event.key.keysym.sym == SDLK_BACKSPACE || event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_TAB - || event.key.keysym.sym == SDLK_LALT - || event.key.keysym.sym == SDLK_RALT))) + || event.key.keysym.sym == SDLK_LALT || event.key.keysym.sym == SDLK_RALT))) { /* Handle key in text tool: */ if (((cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) && cursor_x != -1 && cursor_y != -1) || (cur_tool == TOOL_LABEL - && (cur_label == - LABEL_SELECT - || cur_label == - LABEL_APPLY))) + && (cur_label == LABEL_SELECT || cur_label == LABEL_APPLY))) { static int redraw = 0; wchar_t *im_cp = im_data.s; @@ -3215,22 +3135,21 @@ static void mainloop(void) (L"character 0x%04x %d <%lc> is %d pixels, %lsprintable, key_down 0x%x\n", event.key.keysym.unicode, event.key.keysym.unicode, (key_unicode > L' ') ? event.key.keysym.unicode : L' ', - charsize(event.key.keysym.unicode), - iswprint(key_unicode) ? L"" : L"not ", key_down); + charsize(event.key.keysym.unicode), iswprint(key_unicode) ? L"" : L"not ", key_down); #endif #endif /* Set the text input rectangle for system onscreen keyboards */ if (onscreen_keyboard && !kbd) { - r_tir.y = (float) cursor_y / render_scale; - r_tir.x = (float) cursor_x / render_scale; + r_tir.y = (float)cursor_y / render_scale; + r_tir.x = (float)cursor_x / render_scale; SDL_SetTextInputRect(&r_tir); SDL_StartTextInput(); } /* Discard previous # of redraw characters */ - if ((int) texttool_len <= redraw) + if ((int)texttool_len <= redraw) texttool_len = 0; else texttool_len -= redraw; @@ -3260,8 +3179,7 @@ static void mainloop(void) { texttool_len--; texttool_str[texttool_len] = L'\0'; - playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER, SNDDIST_NEAR); do_render_cur_text(0); @@ -3284,8 +3202,7 @@ static void mainloop(void) int font_height; - font_height = - TuxPaint_Font_FontHeight(getfonthandle(cur_font)); + font_height = TuxPaint_Font_FontHeight(getfonthandle(cur_font)); hide_blinking_cursor(); if (texttool_len > 0) @@ -3316,18 +3233,14 @@ static void mainloop(void) cursor_x = cursor_left; - cursor_y = - min(cursor_y + font_height, canvas->h - font_height); + cursor_y = min(cursor_y + font_height, canvas->h - font_height); /* Reposition the on-screen keyboard if we begin typing over it */ - update_canvas_ex(kbd_rect.x, kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 0); + update_canvas_ex(kbd_rect.x, kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 0); update_screen_rect(&kbd_rect); reposition_onscreen_keyboard(cursor_y); - playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } else if (cur_tool == TOOL_LABEL && label_node_to_edit) { @@ -3339,8 +3252,7 @@ static void mainloop(void) derender_node(&label_node_to_edit); label_node_to_edit = NULL; - playsound(screen, 0, SND_LINE_END, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, SND_LINE_END, 0, SNDPOS_CENTER, SNDDIST_NEAR); if (been_saved) { @@ -3359,27 +3271,22 @@ static void mainloop(void) /* [Enter] to select a node to edit */ DEBUG_PRINTF("Searching for label @ (%d+3,%d+3)\n", - highlighted_label_node->save_x, - highlighted_label_node->save_y); + highlighted_label_node->save_x, highlighted_label_node->save_y); label_node_to_edit = search_label_list(&highlighted_label_node, - highlighted_label_node->save_x + 3, - highlighted_label_node->save_y + 3, 0); + highlighted_label_node->save_x + 3, highlighted_label_node->save_y + 3, 0); if (label_node_to_edit) { select_label_node(&old_x, &old_y); DEBUG_PRINTF("Got a label: \"%ls\" @ (%d,%d)\n", - label_node_to_edit->save_texttool_str, old_x, - old_y); - DEBUG_PRINTF("Cursor now @ (%d,%d); width = %d\n", - cursor_x, cursor_y, cursor_textwidth); + label_node_to_edit->save_texttool_str, old_x, old_y); + DEBUG_PRINTF("Cursor now @ (%d,%d); width = %d\n", cursor_x, cursor_y, cursor_textwidth); cursor_x = label_node_to_edit->save_x; cursor_y = label_node_to_edit->save_y; cursor_left = cursor_x; - DEBUG_PRINTF("Cursor now @ (%d,%d)\n", cursor_x, - cursor_y); + DEBUG_PRINTF("Cursor now @ (%d,%d)\n", cursor_x, cursor_y); } do_render_cur_text(0); @@ -3391,14 +3298,12 @@ static void mainloop(void) label_node_to_edit = search_label_list(&highlighted_label_node, - highlighted_label_node->save_x + 3, - highlighted_label_node->save_y + 3, 0); + highlighted_label_node->save_x + 3, highlighted_label_node->save_y + 3, 0); if (label_node_to_edit) { reposition_onscreen_keyboard(old_y); - apply_label_node(highlighted_label_node->save_x, - highlighted_label_node->save_y); + apply_label_node(highlighted_label_node->save_x, highlighted_label_node->save_y); do_render_cur_text(0); } } @@ -3407,18 +3312,14 @@ static void mainloop(void) /* [Enter] with no text; just move insertion cursor down to the next 'line' */ cursor_x = cursor_left; - cursor_y = - min(cursor_y + font_height, canvas->h - font_height); + cursor_y = min(cursor_y + font_height, canvas->h - font_height); /* Reposition the on-screen keyboard if we begin typing over it */ - update_canvas_ex(kbd_rect.x, kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 0); + update_canvas_ex(kbd_rect.x, kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 0); update_screen_rect(&kbd_rect); reposition_onscreen_keyboard(cursor_y); - playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 0, SND_RETURN, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } #ifdef SPEECH @@ -3460,8 +3361,7 @@ static void mainloop(void) update_screen_rect(&r_tools); } - playsound(screen, 0, SND_CLICK, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 0, SND_CLICK, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } else if (cur_tool == TOOL_LABEL && label_node_to_edit) { @@ -3473,8 +3373,7 @@ static void mainloop(void) derender_node(&label_node_to_edit); label_node_to_edit = NULL; - playsound(screen, 0, SND_LINE_END, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, SND_LINE_END, 0, SNDPOS_CENTER, SNDDIST_NEAR); if (been_saved) { @@ -3487,9 +3386,7 @@ static void mainloop(void) update_screen_rect(&r_tools); } } - else if (cur_tool == TOOL_LABEL - && (cur_label == LABEL_SELECT - || cur_label == LABEL_APPLY)) + else if (cur_tool == TOOL_LABEL && (cur_label == LABEL_SELECT || cur_label == LABEL_APPLY)) { /* [Tab] to cycle between the Labels (nodes) */ @@ -3514,8 +3411,7 @@ static void mainloop(void) #endif /* Printable characters... */ - if (texttool_len < - (sizeof(texttool_str) / sizeof(wchar_t)) - 1) + if (texttool_len < (sizeof(texttool_str) / sizeof(wchar_t)) - 1) { int old_cursor_textwidth = cursor_textwidth; @@ -3541,19 +3437,16 @@ static void mainloop(void) } - if (cursor_x + old_cursor_textwidth <= canvas->w - 50 && - cursor_x + cursor_textwidth > canvas->w - 50) + if (cursor_x + old_cursor_textwidth <= canvas->w - 50 && cursor_x + cursor_textwidth > canvas->w - 50) { - playsound(screen, 0, SND_KEYCLICKRING, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 0, SND_KEYCLICKRING, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } else { /* FIXME: Might be fun to position the sound based on keyboard layout...? */ - playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, SND_KEYCLICK, 0, SNDPOS_CENTER, SNDDIST_NEAR); } } } @@ -3576,45 +3469,39 @@ static void mainloop(void) } else if (event.type == SDL_JOYHATMOTION) { - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); } else if (event.type == SDL_JOYBALLMOTION) { handle_joyballmotion(event, oldpos_x, oldpos_y); } - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) { handle_joybuttonupdownscl(event, oldpos_x, oldpos_y, real_r_tools); } else if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button >= 2 && event.button.button <= 3 && - (no_button_distinction == 0 - && !(HIT(r_tools) - && GRIDHIT_GD(r_tools, gd_tools) == TOOL_PRINT))) + (no_button_distinction == 0 && !(HIT(r_tools) && GRIDHIT_GD(r_tools, gd_tools) == TOOL_PRINT))) { /* They're using the middle or right mouse buttons! */ non_left_click_count++; - if (non_left_click_count == 10 || non_left_click_count == 20 - || (non_left_click_count % 50) == 0) + if (non_left_click_count == 10 || non_left_click_count == 20 || (non_left_click_count % 50) == 0) { /* Pop up an informative animation: */ hide_blinking_cursor(); do_prompt_image_flash(PROMPT_TIP_LEFTCLICK_TXT, PROMPT_TIP_LEFTCLICK_YES, - "", img_mouse, img_mouse_click, NULL, 1, - event.button.x, event.button.y); + "", img_mouse, img_mouse_click, NULL, 1, event.button.x, event.button.y); if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) { if (onscreen_keyboard && !kbd) { - r_tir.y = (float) event.button.y / render_scale; + r_tir.y = (float)event.button.y / render_scale; SDL_SetTextInputRect(&r_tir); SDL_StartTextInput(); } @@ -3624,8 +3511,7 @@ static void mainloop(void) } } else if ((event.type == SDL_MOUSEBUTTONDOWN || - event.type == TP_SDL_MOUSEBUTTONSCROLL) - && event.button.button <= 3) + event.type == TP_SDL_MOUSEBUTTONSCROLL) && event.button.button <= 3) { if (HIT(r_tools)) { @@ -3637,8 +3523,7 @@ static void mainloop(void) magic_switchout(canvas); whicht = tool_scroll + GRIDHIT_GD(real_r_tools, gd_tools); - if (whicht < NUM_TOOLS && tool_avail[whicht] && - (valid_click(event.button.button) || whicht == TOOL_PRINT)) + if (whicht < NUM_TOOLS && tool_avail[whicht] && (valid_click(event.button.button) || whicht == TOOL_PRINT)) { /* Allow middle/right-click on "Print", since [Alt]+click on Mac OS X changes it from left click to middle! */ @@ -3652,8 +3537,7 @@ static void mainloop(void) whicht != TOOL_QUIT) || (cur_tool == TOOL_LABEL && whicht != TOOL_LABEL && whicht != TOOL_NEW && whicht != TOOL_OPEN && - whicht != TOOL_SAVE && whicht != TOOL_PRINT - && whicht != TOOL_QUIT)) + whicht != TOOL_SAVE && whicht != TOOL_PRINT && whicht != TOOL_QUIT)) { if (cursor_x != -1 && cursor_y != -1) { @@ -3676,15 +3560,13 @@ static void mainloop(void) } } } - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, - (button_h * buttons_tall) + r_ttools.h); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, (button_h * buttons_tall) + r_ttools.h); old_tool = cur_tool; cur_tool = whicht; draw_toolbar(); update_screen_rect(&r_tools); - DEBUG_PRINTF("screenrectr_tools %d, %d, %d, %d\n", r_tools.x, - r_tools.y, r_tools.w, r_tools.h); + DEBUG_PRINTF("screenrectr_tools %d, %d, %d, %d\n", r_tools.x, r_tools.y, r_tools.w, r_tools.h); playsound(screen, 1, SND_CLICK, 0, SNDPOS_LEFT, SNDDIST_NEAR); /* FIXME: this "if" is just plain gross */ @@ -3709,10 +3591,8 @@ static void mainloop(void) num_things = num_stamps[stamp_group]; thing_scroll = &(stamp_scroll[stamp_group]); draw_stamps(); - draw_colors(stamp_colorable(cur_stamp[stamp_group]) || - stamp_tintable(cur_stamp[stamp_group])); - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + draw_colors(stamp_colorable(cur_stamp[stamp_group]) || stamp_tintable(cur_stamp[stamp_group])); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); set_active_stamp(); update_stamp_xor(0); } @@ -3756,16 +3636,14 @@ static void mainloop(void) img_btn_up, img_btn_down, img_btn_off, img_btn_nav, img_btn_hold, img_oskdel, img_osktab, img_oskenter, - img_oskcapslock, img_oskshift, - onscreen_keyboard_disable_change); + img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); else kbd = osk_create(strdup("default.layout"), canvas, img_btn_up, img_btn_down, img_btn_off, img_btn_nav, img_btn_hold, img_oskdel, img_osktab, img_oskenter, - img_oskcapslock, img_oskshift, - onscreen_keyboard_disable_change); + img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); } if (kbd == NULL) @@ -3802,7 +3680,7 @@ static void mainloop(void) } if (onscreen_keyboard && !kbd) { - r_tir.y = (float) event.button.y / render_scale; + r_tir.y = (float)event.button.y / render_scale; SDL_SetTextInputRect(&r_tir); SDL_StartTextInput(); } @@ -3869,8 +3747,7 @@ static void mainloop(void) draw_toolbar(); update_screen_rect(&r_tools); shape_tool_mode = SHAPE_TOOL_MODE_DONE; - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } else if (cur_tool == TOOL_REDO) { @@ -3885,8 +3762,7 @@ static void mainloop(void) draw_toolbar(); update_screen_rect(&r_tools); shape_tool_mode = SHAPE_TOOL_MODE_DONE; - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } else if (cur_tool == TOOL_OPEN) { @@ -3918,16 +3794,14 @@ static void mainloop(void) else if (cur_tool == TOOL_STAMP) { draw_stamps(); - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) { draw_fonts(); if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -3955,8 +3829,7 @@ static void mainloop(void) { if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -3966,8 +3839,7 @@ static void mainloop(void) } } else if (old_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); cur_tool = old_tool; draw_toolbar(); @@ -4007,16 +3879,14 @@ static void mainloop(void) else if (cur_tool == TOOL_STAMP) { draw_stamps(); - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) { draw_fonts(); if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -4045,8 +3915,7 @@ static void mainloop(void) { if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -4056,8 +3925,7 @@ static void mainloop(void) } } else if (old_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); cur_tool = old_tool; draw_toolbar(); @@ -4072,8 +3940,7 @@ static void mainloop(void) { if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -4084,8 +3951,7 @@ static void mainloop(void) } } else if (old_tool == TOOL_STAMP) - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); cur_tool = old_tool; draw_toolbar(); @@ -4101,9 +3967,7 @@ static void mainloop(void) else if (((event.button.y < r_tools.y + button_h / 2) && tool_scroll > 0) || ((event.button.y > real_r_tools.y + real_r_tools.h) - && (tool_scroll < - NUM_TOOLS - buttons_tall * gd_tools.cols + - gd_tools.cols))) + && (tool_scroll < NUM_TOOLS - buttons_tall * gd_tools.cols + gd_tools.cols))) { /* Tool up or down scroll buttons */ @@ -4111,8 +3975,7 @@ static void mainloop(void) { /* Tool up scroll button */ tool_scroll -= gd_tools.cols; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); draw_toolbar(); update_screen_rect(&r_tools); @@ -4122,8 +3985,7 @@ static void mainloop(void) /* Tool down scroll button */ tool_scroll += gd_tools.cols; draw_toolbar(); - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); update_screen_rect(&r_tools); } @@ -4142,16 +4004,13 @@ static void mainloop(void) */ scrolling_tool = 1; - scrolltimer_tool = - SDL_AddTimer(REPEAT_SPEED, scrolltimer_tool_callback, - (void *) &scrolltimer_tool_event); + scrolltimer_tool = SDL_AddTimer(REPEAT_SPEED, scrolltimer_tool_callback, (void *)&scrolltimer_tool_event); } else { DEBUG_PRINTF("Continuing scrolling\n"); scrolltimer_tool = - SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_tool_callback, - (void *) &scrolltimer_tool_event); + SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_tool_callback, (void *)&scrolltimer_tool_event); } } } @@ -4165,8 +4024,7 @@ static void mainloop(void) if (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP || cur_tool == TOOL_SHAPES || cur_tool == TOOL_LINES || cur_tool == TOOL_MAGIC || cur_tool == TOOL_TEXT || - cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL || - cur_tool == TOOL_FILL) + cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL || cur_tool == TOOL_FILL) { int num_rows_needed; SDL_Rect r_controls; @@ -4190,9 +4048,12 @@ static void mainloop(void) if (!disable_stamp_controls) { /* Account for stamp controls and group changing (left/right) buttons */ - if (!no_stamp_rotation) { + if (!no_stamp_rotation) + { gd_controls.rows = 4; - } else { + } + else + { gd_controls.rows = 3; } gd_controls.cols = 2; @@ -4255,8 +4116,7 @@ static void mainloop(void) /* number of whole or partial rows that will be needed (can make this per-tool if variable columns needed) */ - num_rows_needed = - (num_things + gd_items.cols - 1) / gd_items.cols; + num_rows_needed = (num_things + gd_items.cols - 1) / gd_items.cols; do_draw = 0; @@ -4295,11 +4155,9 @@ static void mainloop(void) /* ...and there was something there to click */ toolopt_changed = 1; #ifndef NOSOUND - if (cur_tool != TOOL_STAMP - || stamp_data[stamp_group][which]->ssnd == NULL) + if (cur_tool != TOOL_STAMP || stamp_data[stamp_group][which]->ssnd == NULL) { - playsound(screen, 1, SND_BLEEP, 0, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 1, SND_BLEEP, 0, SNDPOS_RIGHT, SNDDIST_NEAR); } #endif cur_thing = which; @@ -4314,7 +4172,8 @@ static void mainloop(void) if (cur_tool == TOOL_STAMP) { - if (no_stamp_rotation && which > 1) { + if (no_stamp_rotation && which > 1) + { /* No column for stamp rotation control, pretend the lower buttons are lower */ which += 2; } @@ -4322,8 +4181,7 @@ static void mainloop(void) if (stamp_tool_mode == STAMP_TOOL_MODE_ROTATE) { stamp_xor(stamp_place_x, stamp_place_y); - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } /* Stamp controls! */ @@ -4333,30 +4191,26 @@ static void mainloop(void) { /* Grow/Shrink Controls: */ int old_size; + #ifdef DEBUG float choice; #endif - old_size = - stamp_data[stamp_group][cur_stamp[stamp_group]]->size; + old_size = stamp_data[stamp_group][cur_stamp[stamp_group]]->size; - stamp_data[stamp_group][cur_stamp[stamp_group]]->size = - (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 - /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ - ) * (event.button.x - - (WINDOW_WIDTH - r_ttoolopt.w))) / r_ttoolopt.w) + + stamp_data[stamp_group][cur_stamp[stamp_group]]->size = (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 + /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ + ) * (event.button.x - + (WINDOW_WIDTH - + r_ttoolopt.w))) / r_ttoolopt.w) + MIN_STAMP_SIZE; DEBUG_PRINTF("Old size = %d, Chose %0.4f, New size =%d\n", - old_size, choice, - stamp_data[stamp_group][cur_stamp[stamp_group]]->size); + old_size, choice, stamp_data[stamp_group][cur_stamp[stamp_group]]->size); - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size < - old_size) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size < old_size) control_sound = SND_SHRINK; - else - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size - > old_size) + else if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size > old_size) control_sound = SND_GROW; } else if (which == 4 || which == 5) @@ -4365,26 +4219,21 @@ static void mainloop(void) if (which == 5) { /* Top right button: Flip: */ - if (stamp_data[stamp_group] - [cur_stamp[stamp_group]]->flipable) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->flipable) { stamp_data[stamp_group][cur_stamp[stamp_group]]->flipped - = - !stamp_data[stamp_group][cur_stamp - [stamp_group]]->flipped; + = !stamp_data[stamp_group][cur_stamp[stamp_group]]->flipped; control_sound = SND_FLIP; } } else { /* Top left button: Mirror: */ - if (stamp_data[stamp_group] - [cur_stamp[stamp_group]]->mirrorable) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->mirrorable) { stamp_data[stamp_group][cur_stamp [stamp_group]]->mirrored = - !stamp_data[stamp_group][cur_stamp - [stamp_group]]->mirrored; + !stamp_data[stamp_group][cur_stamp[stamp_group]]->mirrored; control_sound = SND_MIRROR; } } @@ -4433,8 +4282,7 @@ static void mainloop(void) if (control_sound != -1) { - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); draw_stamps(); update_screen_rect(&r_toolopt); set_active_stamp(); @@ -4476,8 +4324,7 @@ static void mainloop(void) magic_group = 0; } } - while (num_magics[magic_group] == 0 - && tries < MAX_MAGIC_GROUPS); + while (num_magics[magic_group] == 0 && tries < MAX_MAGIC_GROUPS); keybd_flag = 0; cur_thing = cur_magic[magic_group]; @@ -4497,15 +4344,14 @@ static void mainloop(void) magic_switchin(canvas); - playsound(screen, 0, SND_CLICK, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, SND_CLICK, 0, SNDPOS_CENTER, SNDDIST_NEAR); } else { - if (!disable_magic_controls && (which == 2 || which == 3)) { + if (!disable_magic_controls && (which == 2 || which == 3)) + { /* Magic controls! */ - if (which == 3 - && magics[grp][cur].avail_modes & MODE_FULLSCREEN) + if (which == 3 && magics[grp][cur].avail_modes & MODE_FULLSCREEN) { magic_switchout(canvas); magics[grp][cur].mode = MODE_FULLSCREEN; @@ -4513,8 +4359,7 @@ static void mainloop(void) draw_magic(); update_screen_rect(&r_toolopt); } - else if (which == 2 - && magics[grp][cur].avail_modes & MODE_PAINT) + else if (which == 2 && magics[grp][cur].avail_modes & MODE_PAINT) { magic_switchout(canvas); magics[grp][cur].mode = MODE_PAINT; @@ -4522,9 +4367,7 @@ static void mainloop(void) draw_magic(); update_screen_rect(&r_toolopt); } - else if (which == 2 - && magics[grp][cur].avail_modes & - MODE_PAINT_WITH_PREVIEW) + else if (which == 2 && magics[grp][cur].avail_modes & MODE_PAINT_WITH_PREVIEW) { magic_switchout(canvas); magics[grp][cur].mode = MODE_PAINT_WITH_PREVIEW; @@ -4532,8 +4375,7 @@ static void mainloop(void) draw_magic(); update_screen_rect(&r_toolopt); } - else if (which == 2 - && magics[grp][cur].avail_modes & MODE_ONECLICK) + else if (which == 2 && magics[grp][cur].avail_modes & MODE_ONECLICK) { magic_switchout(canvas); magics[grp][cur].mode = MODE_ONECLICK; @@ -4542,19 +4384,25 @@ static void mainloop(void) update_screen_rect(&r_toolopt); } playsound(screen, 0, SND_CLICK, 0, SNDPOS_CENTER, SNDDIST_NEAR); - } else if (!disable_magic_sizes) { + } + else if (!disable_magic_sizes) + { int mode; mode = magic_modeint(magics[grp][cur].mode); - if (magics[grp][cur].sizes[mode] > 1) { + if (magics[grp][cur].sizes[mode] > 1) + { int old_size, new_size; old_size = magics[grp][cur].size[mode]; - new_size = ((magics[grp][cur].sizes[mode] * (event.button.x - (WINDOW_WIDTH - r_ttoolopt.w))) / r_ttoolopt.w) + 1; + new_size = + ((magics[grp][cur].sizes[mode] * (event.button.x - (WINDOW_WIDTH - r_ttoolopt.w))) / + r_ttoolopt.w) + 1; - if (new_size != old_size) { + if (new_size != old_size) + { magics[grp][cur].size[mode] = new_size; magic_set_size(); @@ -4577,8 +4425,7 @@ static void mainloop(void) draw_shapes(); update_screen_rect(&r_toolopt); draw_tux_text(TUX_GREAT, shapemode_tips[shape_mode], 1); - playsound(screen, 0, SND_CLICK, 0, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 0, SND_CLICK, 0, SNDPOS_RIGHT, SNDDIST_NEAR); update_screen_rect(&r_tuxarea); toolopt_changed = 0; } @@ -4646,8 +4493,7 @@ static void mainloop(void) } if (control_sound != -1) { - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); if (cur_tool == TOOL_TEXT) /* Huh? It had better be! */ @@ -4658,11 +4504,9 @@ static void mainloop(void) for (i = 0; i < num_font_families; i++) { - if (user_font_families[i] - && user_font_families[i]->handle) + if (user_font_families[i] && user_font_families[i]->handle) { - TuxPaint_Font_CloseFont(user_font_families - [i]->handle); + TuxPaint_Font_CloseFont(user_font_families[i]->handle); user_font_families[i]->handle = NULL; } } @@ -4746,13 +4590,10 @@ static void mainloop(void) { /* Already in label select mode; turn it off */ cur_label = LABEL_LABEL; - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, - (button_h * buttons_tall) + - r_ttoolopt.h); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, (button_h * buttons_tall) + r_ttoolopt.h); if (onscreen_keyboard) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -4762,8 +4603,7 @@ static void mainloop(void) } draw_tux_text(TUX_GREAT, tool_tips[TOOL_LABEL], 1); - playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } else { @@ -4771,9 +4611,7 @@ static void mainloop(void) if (are_labels()) { update_canvas_ex_r(kbd_rect.x - r_ttools.w, - kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 1); + kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 1); if (texttool_len > 0) { rec_undo_buffer(); @@ -4793,10 +4631,8 @@ static void mainloop(void) cur_label = LABEL_SELECT; highlight_label_nodes(); - draw_tux_text(TUX_GREAT, TIP_LABEL_SELECTOR_ENABLED, - 1); - playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + draw_tux_text(TUX_GREAT, TIP_LABEL_SELECTOR_ENABLED, 1); + playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } } toolopt_changed = 1; @@ -4808,19 +4644,15 @@ static void mainloop(void) { /* Already in label apply mode; turn it off */ cur_label = LABEL_LABEL; - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, - (button_h * buttons_tall) + - r_ttoolopt.h); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, (button_h * buttons_tall) + r_ttoolopt.h); if (onscreen_keyboard) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } draw_tux_text(TUX_GREAT, tool_tips[TOOL_LABEL], 1); - playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } else { @@ -4828,9 +4660,7 @@ static void mainloop(void) if (are_labels()) { update_canvas_ex_r(kbd_rect.x - r_ttools.w, - kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 1); + kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 1); if (texttool_len > 0) { rec_undo_buffer(); @@ -4850,10 +4680,8 @@ static void mainloop(void) cur_label = LABEL_APPLY; highlight_label_nodes(); - draw_tux_text(TUX_GREAT, TIP_LABEL_APPLIER_ENABLED, - 1); - playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + draw_tux_text(TUX_GREAT, TIP_LABEL_APPLIER_ENABLED, 1); + playsound(screen, 1, SND_CLICK, 1, SNDPOS_RIGHT, SNDDIST_NEAR); } } @@ -4864,8 +4692,7 @@ static void mainloop(void) if (control_sound != -1) { - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); if (cur_tool == TOOL_LABEL) /* Huh? It had better be! */ @@ -4876,11 +4703,9 @@ static void mainloop(void) for (i = 0; i < num_font_families; i++) { - if (user_font_families[i] - && user_font_families[i]->handle) + if (user_font_families[i] && user_font_families[i]->handle) { - TuxPaint_Font_CloseFont(user_font_families - [i]->handle); + TuxPaint_Font_CloseFont(user_font_families[i]->handle); user_font_families[i]->handle = NULL; } } @@ -4902,12 +4727,9 @@ static void mainloop(void) prev_size = brushes_spacing[cur_brush]; chosen = ((BRUSH_SPACING_SIZES * strike) / r_ttoolopt.w); - frame_w = - img_brushes[cur_brush]->w / abs(brushes_frames[cur_brush]); + frame_w = img_brushes[cur_brush]->w / abs(brushes_frames[cur_brush]); w = frame_w / (brushes_directional[cur_brush] ? 3 : 1); - h = - img_brushes[cur_brush]->h / - (brushes_directional[cur_brush] ? 3 : 1); + h = img_brushes[cur_brush]->h / (brushes_directional[cur_brush] ? 3 : 1); /* Spacing ranges from 0px to "N x the max dimension of the brush" (so a 48x48 brush would have a spacing of 48 if the center option is chosen) */ @@ -4917,24 +4739,19 @@ static void mainloop(void) } else { - new_size = - (chosen * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / - (BRUSH_SPACING_SIZES - 1); + new_size = (chosen * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / (BRUSH_SPACING_SIZES - 1); } if (new_size != brushes_spacing_default[cur_brush]) { - prev_new_size = - ((chosen - 1) * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / - (BRUSH_SPACING_SIZES - 1); - next_new_size = - ((chosen + 1) * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / - (BRUSH_SPACING_SIZES - 1); + prev_new_size = ((chosen - 1) * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / (BRUSH_SPACING_SIZES - 1); + next_new_size = ((chosen + 1) * max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER) / (BRUSH_SPACING_SIZES - 1); if (prev_new_size < brushes_spacing_default[cur_brush] && next_new_size > brushes_spacing_default[cur_brush]) { - DEBUG_PRINTF("Nudging %d brush spacing to my default: %d\n", new_size, brushes_spacing_default[cur_brush]); + DEBUG_PRINTF("Nudging %d brush spacing to my default: %d\n", new_size, + brushes_spacing_default[cur_brush]); new_size = brushes_spacing_default[cur_brush]; } } @@ -4970,11 +4787,10 @@ static void mainloop(void) /* Spacing is larger than the brush */ double ratio, i, f; - ratio = (float) new_size / (float) max(w, h); + ratio = (float)new_size / (float)max(w, h); f = modf(ratio, &i); - if (f > - (SLOPPY_FRAC_MAX - SLOPPY_FRAC_MIN) / SLOPPY_FRAC_MAX) + if (f > (SLOPPY_FRAC_MAX - SLOPPY_FRAC_MIN) / SLOPPY_FRAC_MAX) { i++; f = 0.0; @@ -4987,17 +4803,14 @@ static void mainloop(void) if (f == 0.0) { /* Spacing ratio has no fractional part (e.g., "...4 times as big...") */ - snprintf(tmp_tip, sizeof(tmp_tip), - gettext(TIP_BRUSH_SPACING_MORE), (int) i); + snprintf(tmp_tip, sizeof(tmp_tip), gettext(TIP_BRUSH_SPACING_MORE), (int)i); } else { /* Spacing ratio has a fractional part (e.g., "... 2 1/2 times as big...") */ sloppy_frac(f, &numer, &denom); - snprintf(tmp_tip, sizeof(tmp_tip), - gettext(TIP_BRUSH_SPACING_MORE_FRAC), (int) i, - numer, denom); + snprintf(tmp_tip, sizeof(tmp_tip), gettext(TIP_BRUSH_SPACING_MORE_FRAC), (int)i, numer, denom); } draw_tux_text(TUX_GREAT, tmp_tip, 1); @@ -5005,15 +4818,12 @@ static void mainloop(void) else if (new_size < max(w, h)) { /* Spacing is smaller than the brush (e.g., "... 1/3 as big...") */ - sloppy_frac((float) new_size / (float) max(w, h), &numer, - &denom); - snprintf(tmp_tip, sizeof(tmp_tip), - gettext(TIP_BRUSH_SPACING_LESS), numer, denom); + sloppy_frac((float)new_size / (float)max(w, h), &numer, &denom); + snprintf(tmp_tip, sizeof(tmp_tip), gettext(TIP_BRUSH_SPACING_LESS), numer, denom); draw_tux_text(TUX_GREAT, tmp_tip, 1); } - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); } } } @@ -5028,8 +4838,7 @@ static void mainloop(void) { *thing_scroll += is_upper ? -gd_items.cols : gd_items.cols; do_draw = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_RIGHT, SNDDIST_NEAR); if (scrolltimer_selector != TIMERID_NONE) { @@ -5040,8 +4849,7 @@ static void mainloop(void) if (!scrolling_selector && event.type == SDL_MOUSEBUTTONDOWN) { DEBUG_PRINTF("Starting scrolling\n"); - memcpy(&scrolltimer_selector_event, &event, - sizeof(SDL_Event)); + memcpy(&scrolltimer_selector_event, &event, sizeof(SDL_Event)); scrolltimer_selector_event.type = TP_SDL_MOUSEBUTTONSCROLL; /* @@ -5053,21 +4861,16 @@ static void mainloop(void) scrolling_selector = 1; scrolltimer_selector = - SDL_AddTimer(REPEAT_SPEED, scrolltimer_selector_callback, - (void *) &scrolltimer_selector_event); + SDL_AddTimer(REPEAT_SPEED, scrolltimer_selector_callback, (void *)&scrolltimer_selector_event); } else { DEBUG_PRINTF("Continuing scrolling\n"); scrolltimer_selector = - SDL_AddTimer(REPEAT_SPEED / 3, - scrolltimer_selector_callback, - (void *) &scrolltimer_selector_event); + SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_selector_callback, (void *)&scrolltimer_selector_event); } - if (*thing_scroll == 0 - || *thing_scroll / gd_items.cols == - num_rows_needed - gd_items.rows) + if (*thing_scroll == 0 || *thing_scroll / gd_items.cols == num_rows_needed - gd_items.rows) { do_setcursor(cursor_arrow); if (scrolling_selector) @@ -5166,8 +4969,7 @@ static void mainloop(void) { Mix_ChannelFinished(NULL); /* Prevents multiple clicks from toggling between SFX and desc sound, rather than always playing SFX first, then desc sound... */ - Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->ssnd, - 0); + Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->ssnd, 0); /* If there's a description sound, play it after the SFX! */ @@ -5182,9 +4984,7 @@ static void mainloop(void) if (stamp_data[stamp_group][cur_thing]->sdesc != NULL) { - Mix_PlayChannel(2, - stamp_data[stamp_group][cur_thing]->sdesc, - 0); + Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->sdesc, 0); } } } @@ -5195,8 +4995,7 @@ static void mainloop(void) if (stamp_tool_mode == STAMP_TOOL_MODE_ROTATE) { stamp_xor(stamp_place_x, stamp_place_y); - reset_stamps(&stamp_xored_rt, &stamp_place_x, - &stamp_place_y, &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); } cur_stamp[stamp_group] = cur_thing; set_active_stamp(); @@ -5207,8 +5006,7 @@ static void mainloop(void) if (do_draw) draw_stamps(); - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->stxt != - NULL) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->stxt != NULL) { DEBUG_PRINTF ("stamp_data[stamp_group][cur_stamp[stamp_group]]->stxt = %s\n", @@ -5217,17 +5015,13 @@ static void mainloop(void) draw_tux_text_ex(TUX_GREAT, stamp_data[stamp_group][cur_stamp [stamp_group]]->stxt, - 1, - stamp_data[stamp_group][cur_stamp - [stamp_group]]-> - locale_text); + 1, stamp_data[stamp_group][cur_stamp[stamp_group]]->locale_text); } else draw_tux_text(TUX_GREAT, "", 0); /* Enable or disable color selector: */ - draw_colors(stamp_colorable(cur_stamp[stamp_group]) - || stamp_tintable(cur_stamp[stamp_group])); + draw_colors(stamp_colorable(cur_stamp[stamp_group]) || stamp_tintable(cur_stamp[stamp_group])); if (!scrolling_selector) { stamp_xor(canvas->w / 2, canvas->h / 2); @@ -5238,9 +5032,7 @@ static void mainloop(void) canvas->h / 2 - (CUR_STAMP_H + 1) / 2 + r_canvas.y, canvas->w / 2 + (CUR_STAMP_W + 1) / 2 + - r_canvas.x, - canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + - r_canvas.y); + r_canvas.x, canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + r_canvas.y); } } else if (cur_tool == TOOL_SHAPES) @@ -5288,9 +5080,7 @@ static void mainloop(void) magic_switchin(canvas); } - draw_tux_text(TUX_GREAT, - magics[grp][cur].tip[magic_modeint - (magics[grp][cur].mode)], 1); + draw_tux_text(TUX_GREAT, magics[grp][cur].tip[magic_modeint(magics[grp][cur].mode)], 1); if (do_draw) draw_magic(); @@ -5318,9 +5108,8 @@ static void mainloop(void) cur_color = whichc; draw_tux_text(TUX_KISS, color_names[cur_color], 1); - if (cur_color == (unsigned) COLOR_PICKER - || cur_color == (unsigned) COLOR_SELECTOR - || cur_color == (unsigned) COLOR_MIXER) + if (cur_color == (unsigned)COLOR_PICKER + || cur_color == (unsigned)COLOR_SELECTOR || cur_color == (unsigned)COLOR_MIXER) { int chose_color; @@ -5330,11 +5119,11 @@ static void mainloop(void) draw_none(); chose_color = 0; - if (cur_color == (unsigned) COLOR_PICKER) + if (cur_color == (unsigned)COLOR_PICKER) chose_color = do_color_picker(old_color); - else if (cur_color == (unsigned) COLOR_SELECTOR) + else if (cur_color == (unsigned)COLOR_SELECTOR) chose_color = do_color_sel(0); - else if (cur_color == (unsigned) COLOR_MIXER) + else if (cur_color == (unsigned)COLOR_MIXER) { chose_color = do_color_mix(); if (!chose_color) @@ -5345,8 +5134,7 @@ static void mainloop(void) { if (onscreen_keyboard && kbd) { - SDL_BlitSurface(kbd->surface, &kbd->rect, screen, - &kbd_rect); + SDL_BlitSurface(kbd->surface, &kbd->rect, screen, &kbd_rect); update_screen_rect(&kbd_rect); } @@ -5381,9 +5169,7 @@ static void mainloop(void) canvas->h / 2 - (CUR_STAMP_H + 1) / 2 + r_canvas.y, canvas->w / 2 + (CUR_STAMP_W + 1) / 2 + - r_canvas.x, - canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + - r_canvas.y); + r_canvas.x, canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + r_canvas.y); } draw_stamps(); } @@ -5397,11 +5183,9 @@ static void mainloop(void) draw_fills(); if (chose_color) - playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR); else - playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, SNDDIST_NEAR); SDL_Flip(screen); } @@ -5409,23 +5193,20 @@ static void mainloop(void) { draw_colors(COLORSEL_REFRESH); - playsound(screen, 1, SND_BUBBLE, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_BUBBLE, 1, event.button.x, SNDDIST_NEAR); } handle_color_changed(); } } } - else if (HIT(r_canvas) && valid_click(event.button.button) - && keyglobal == 0) + else if (HIT(r_canvas) && valid_click(event.button.button) && keyglobal == 0) { const Uint8 *kbd_state; kbd_state = SDL_GetKeyboardState(NULL); - if ((kbd_state[SDL_SCANCODE_LCTRL] || kbd_state[SDL_SCANCODE_RCTRL]) - && colors_are_selectable) + if ((kbd_state[SDL_SCANCODE_LCTRL] || kbd_state[SDL_SCANCODE_RCTRL]) && colors_are_selectable) { int chose_color; @@ -5437,8 +5218,7 @@ static void mainloop(void) if (chose_color) { - playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR); cur_color = COLOR_SELECTOR; handle_color_changed(); } @@ -5455,8 +5235,7 @@ static void mainloop(void) if ((cur_tool != TOOL_SHAPES || shape_mode == SHAPE_TOOL_MODE_DONE) && (cur_tool != TOOL_STAMP || stamp_tool_mode == STAMP_TOOL_MODE_PLACE) && - cur_tool != TOOL_TEXT && - cur_tool != TOOL_LABEL) + cur_tool != TOOL_TEXT && cur_tool != TOOL_LABEL) { do_quick_eraser(); } @@ -5496,8 +5275,7 @@ static void mainloop(void) reset_brush_counter(); /* brush_draw(old_x, old_y, old_x, old_y, 1); fixes SF #1934883? */ - playsound(screen, 0, paintsound(img_cur_brush_w), 1, - event.button.x, SNDDIST_NEAR); + playsound(screen, 0, paintsound(img_cur_brush_w), 1, event.button.x, SNDDIST_NEAR); if (mouseaccessibility) emulate_button_pressed = !emulate_button_pressed; @@ -5518,8 +5296,7 @@ static void mainloop(void) /* brush_draw(old_x, old_y, old_x, old_y, 1); fixes sf #1934883? */ - playsound(screen, 1, SND_LINE_START, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_START, 1, event.button.x, SNDDIST_NEAR); draw_tux_text(TUX_BORED, TIP_LINE_START, 1); } if (mouseaccessibility) @@ -5540,8 +5317,7 @@ static void mainloop(void) shape_tool_mode = SHAPE_TOOL_MODE_STRETCH; - playsound(screen, 1, SND_LINE_START, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_START, 1, event.button.x, SNDDIST_NEAR); draw_tux_text(TUX_BORED, TIP_SHAPE_START, 1); if (mouseaccessibility) emulate_button_pressed = 1; @@ -5557,21 +5333,16 @@ static void mainloop(void) /* (Arbitrarily large...) */ reset_brush_counter(); - playsound(screen, 1, SND_LINE_END, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_END, 1, event.button.x, SNDDIST_NEAR); do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, shape_rotation(shape_ctr_x, shape_ctr_y, event.button.x - - r_canvas.x, - event.button.y - - r_canvas.y), 1); + r_canvas.x, event.button.y - r_canvas.y), 1); shape_tool_mode = SHAPE_TOOL_MODE_DONE; draw_tux_text(TUX_GREAT, - shape_tool_tips[simple_shapes ? - SHAPE_COMPLEXITY_SIMPLE : - SHAPE_COMPLEXITY_NORMAL], 1); + shape_tool_tips[simple_shapes ? SHAPE_COMPLEXITY_SIMPLE : SHAPE_COMPLEXITY_NORMAL], 1); } } else if (shape_tool_mode == SHAPE_TOOL_MODE_STRETCH) @@ -5620,19 +5391,14 @@ static void mainloop(void) reset_touched(); - magic_funcs[magics[grp][cur].handle_idx]. - click(magic_api_struct, magics[grp][cur].idx, - magics[grp][cur].mode, canvas, last, old_x, old_y, - &update_rect); + magic_funcs[magics[grp][cur].handle_idx].click(magic_api_struct, magics[grp][cur].idx, + magics[grp][cur].mode, canvas, last, old_x, old_y, + &update_rect); - draw_tux_text(TUX_GREAT, - magics[grp][cur].tip[magic_modeint - (magics[grp][cur].mode)], - 1); + draw_tux_text(TUX_GREAT, magics[grp][cur].tip[magic_modeint(magics[grp][cur].mode)], 1); update_canvas(update_rect.x, update_rect.y, - update_rect.x + update_rect.w, - update_rect.y + update_rect.h); + update_rect.x + update_rect.w, update_rect.y + update_rect.h); } if (mouseaccessibility) @@ -5659,12 +5425,8 @@ static void mainloop(void) /* Fill */ draw_color = SDL_MapRGB(canvas->format, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2]); - canv_color = - getpixels[canvas->format->BytesPerPixel] (canvas, old_x, - old_y); + color_hexes[cur_color][0], color_hexes[cur_color][1], color_hexes[cur_color][2]); + canv_color = getpixels[canvas->format->BytesPerPixel] (canvas, old_x, old_y); fill_x = old_x; fill_y = old_y; @@ -5702,8 +5464,7 @@ static void mainloop(void) { /* Flood fill a solid color */ do_flood_fill(screen, texture, renderer, last, canvas, - old_x, old_y, draw_color, canv_color, &x1, - &y1, &x2, &y2, sim_flood_touched); + old_x, old_y, draw_color, canv_color, &x1, &y1, &x2, &y2, sim_flood_touched); update_canvas(x1, y1, x2, y2); } @@ -5713,18 +5474,15 @@ static void mainloop(void) tmp_canvas = SDL_CreateRGBSurface(canvas->flags, canvas->w, canvas->h, - canvas->format-> - BitsPerPixel, + canvas->format->BitsPerPixel, canvas->format->Rmask, canvas->format->Gmask, - canvas->format->Bmask, - canvas->format->Amask); + canvas->format->Bmask, canvas->format->Amask); SDL_BlitSurface(canvas, NULL, tmp_canvas, NULL); simulate_flood_fill(screen, texture, renderer, last, tmp_canvas, old_x, old_y, draw_color, - canv_color, &x1, &y1, &x2, &y2, - sim_flood_touched); + canv_color, &x1, &y1, &x2, &y2, sim_flood_touched); SDL_FreeSurface(tmp_canvas); sim_flood_x1 = x1; @@ -5736,9 +5494,7 @@ static void mainloop(void) { /* Radial gradient */ draw_radial_gradient(canvas, sim_flood_x1, sim_flood_y1, - sim_flood_x2, sim_flood_y2, old_x, - old_y, draw_color, - sim_flood_touched); + sim_flood_x2, sim_flood_y2, old_x, old_y, draw_color, sim_flood_touched); } else if (cur_fill == FILL_GRADIENT_SHAPED) { @@ -5750,9 +5506,7 @@ static void mainloop(void) /* Start a linear gradient */ draw_linear_gradient(canvas, canvas, sim_flood_x1, sim_flood_y1, sim_flood_x2, - sim_flood_y2, fill_x, fill_y, old_x, - old_y + 1, draw_color, - sim_flood_touched); + sim_flood_y2, fill_x, fill_y, old_x, old_y + 1, draw_color, sim_flood_touched); fill_drag_started = 1; } else if (cur_fill == FILL_BRUSH) @@ -5760,8 +5514,7 @@ static void mainloop(void) /* Start painting within the fill area */ draw_brush_fill(canvas, sim_flood_x1, sim_flood_y1, sim_flood_x2, sim_flood_y2, fill_x, - fill_y, old_x, old_y, draw_color, - sim_flood_touched, &x1, &y1, &x2, &y2); + fill_y, old_x, old_y, draw_color, sim_flood_touched, &x1, &y1, &x2, &y2); } update_canvas(x1, y1, x2, y2); @@ -5775,7 +5528,7 @@ static void mainloop(void) { if (onscreen_keyboard && !kbd) { - r_tir.y = (float) old_y / render_scale; + r_tir.y = (float)old_y / render_scale; SDL_SetTextInputRect(&r_tir); SDL_StartTextInput(); } @@ -5787,16 +5540,12 @@ static void mainloop(void) DEBUG_PRINTF("Searching for label @ (%d,%d)\n", old_x, old_y); - label_node_to_edit = - search_label_list(&highlighted_label_node, old_x, old_y, 0); + label_node_to_edit = search_label_list(&highlighted_label_node, old_x, old_y, 0); if (label_node_to_edit) { - DEBUG_PRINTF("Got a label: \"%ls\" @ (%d,%d)\n", - label_node_to_edit->save_texttool_str, old_x, - old_y); - DEBUG_PRINTF("Cursor now @ (%d,%d); width = %d\n", cursor_x, - cursor_y, cursor_textwidth); + DEBUG_PRINTF("Got a label: \"%ls\" @ (%d,%d)\n", label_node_to_edit->save_texttool_str, old_x, old_y); + DEBUG_PRINTF("Cursor now @ (%d,%d); width = %d\n", cursor_x, cursor_y, cursor_textwidth); select_label_node(&old_x, &old_y); } } @@ -5804,8 +5553,7 @@ static void mainloop(void) { /* Click to select a node to apply it to the canvas */ - label_node_to_edit = - search_label_list(&highlighted_label_node, old_x, old_y, 0); + label_node_to_edit = search_label_list(&highlighted_label_node, old_x, old_y, 0); if (label_node_to_edit) apply_label_node(old_x, old_y); } @@ -5826,20 +5574,14 @@ static void mainloop(void) */ } if (onscreen_keyboard && kbd && HIT(kbd_rect) - && !(cur_tool == TOOL_LABEL - && (cur_label == LABEL_SELECT - || cur_label == LABEL_APPLY))) + && !(cur_tool == TOOL_LABEL && (cur_label == LABEL_SELECT || cur_label == LABEL_APPLY))) { - new_kbd = - osk_clicked(kbd, old_x - kbd_rect.x + r_canvas.x, - old_y - kbd_rect.y + r_canvas.y); + new_kbd = osk_clicked(kbd, old_x - kbd_rect.x + r_canvas.x, old_y - kbd_rect.y + r_canvas.y); /* keyboard has changed, erase the old, note that the old kbd has yet been freed. */ if (new_kbd != kbd) { kbd = new_kbd; - update_canvas_ex(kbd_rect.x, kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 0); + update_canvas_ex(kbd_rect.x, kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 0); /* set kbd_rect dimensions according to the new keyboard */ reposition_onscreen_keyboard(-1); } @@ -5853,13 +5595,9 @@ static void mainloop(void) cursor_left = old_x; if (onscreen_keyboard - && !(cur_tool == TOOL_LABEL - && (cur_label == LABEL_SELECT - || cur_label == LABEL_APPLY))) + && !(cur_tool == TOOL_LABEL && (cur_label == LABEL_SELECT || cur_label == LABEL_APPLY))) { - update_canvas_ex(kbd_rect.x, kbd_rect.y, - kbd_rect.x + kbd_rect.w, - kbd_rect.y + kbd_rect.h, 0); + update_canvas_ex(kbd_rect.x, kbd_rect.y, kbd_rect.x + kbd_rect.w, kbd_rect.y + kbd_rect.h, 0); update_screen_rect(&kbd_rect); reposition_onscreen_keyboard(old_y); } @@ -5867,7 +5605,7 @@ static void mainloop(void) if (onscreen_keyboard && !kbd) { - r_tir.y = (float) cursor_y / render_scale; + r_tir.y = (float)cursor_y / render_scale; SDL_SetTextInputRect(&r_tir); SDL_StartTextInput(); } @@ -5887,22 +5625,17 @@ static void mainloop(void) { which = GRIDHIT_GD(r_sfx, gd_sfx); - if (which == 0 - && !stamp_data[stamp_group][cur_stamp[stamp_group]]->no_sound) + if (which == 0 && !stamp_data[stamp_group][cur_stamp[stamp_group]]->no_sound) { /* Re-play sound effect: */ Mix_ChannelFinished(NULL); Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->ssnd, 0); } - else if (which == 1 - && - !stamp_data[stamp_group][cur_stamp - [stamp_group]]->no_descsound) + else if (which == 1 && !stamp_data[stamp_group][cur_stamp[stamp_group]]->no_descsound) { Mix_ChannelFinished(NULL); - Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->sdesc, - 0); + Mix_PlayChannel(2, stamp_data[stamp_group][cur_thing]->sdesc, 0); } magic_switchout(canvas); @@ -5933,8 +5666,7 @@ static void mainloop(void) if (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP || cur_tool == TOOL_SHAPES || cur_tool == TOOL_LINES || cur_tool == TOOL_MAGIC || cur_tool == TOOL_TEXT || - cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL || - cur_tool == TOOL_FILL) + cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL || cur_tool == TOOL_FILL) { /* Left tools scroll (via scroll wheel) */ @@ -5945,15 +5677,13 @@ static void mainloop(void) if (is_upper && tool_scroll > 0) { tool_scroll -= gd_tools.cols; - playsound(screen, 1, SND_SCROLL, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, event.button.x, SNDDIST_NEAR); draw_toolbar(); } else if (!is_upper && tool_scroll < NUM_TOOLS - 12 - TOOLOFFSET) { tool_scroll += gd_tools.cols; - playsound(screen, 1, SND_SCROLL, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, event.button.x, SNDDIST_NEAR); draw_toolbar(); } @@ -5974,10 +5704,7 @@ static void mainloop(void) } else if (tool_avail[((event.button.x - r_tools.x) / button_w) + - ((event.button.y - - r_tools.y - - button_h / 2) / button_h) * gd_tools.cols + - tool_scroll]) + ((event.button.y - r_tools.y - button_h / 2) / button_h) * gd_tools.cols + tool_scroll]) { do_setcursor(cursor_hand); } @@ -6063,8 +5790,7 @@ static void mainloop(void) /* number of whole or partial rows that will be needed (can make this per-tool if variable columns needed) */ - num_rows_needed = - (num_things + gd_items.cols - 1) / gd_items.cols; + num_rows_needed = (num_things + gd_items.cols - 1) / gd_items.cols; do_draw = 0; @@ -6105,8 +5831,7 @@ static void mainloop(void) { *thing_scroll += is_upper ? -gd_items.cols : gd_items.cols; do_draw = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_RIGHT, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_RIGHT, SNDDIST_NEAR); if (*thing_scroll == 0) { do_setcursor(cursor_arrow); @@ -6168,13 +5893,13 @@ static void mainloop(void) if (event.user.data1 != NULL) { - if (((unsigned char *) event.user.data1)[0] == '=') + if (((unsigned char *)event.user.data1)[0] == '=') { - draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1 + 1, 1, (int) (intptr_t) event.user.data2); //EP added (intptr_t) to avoid warning on x64 + draw_tux_text_ex(TUX_GREAT, (char *)event.user.data1 + 1, 1, (int)(intptr_t) event.user.data2); //EP added (intptr_t) to avoid warning on x64 } else { - draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1, 0, (int) (intptr_t) event.user.data2); //EP added (intptr_t) to avoid warning on x64 + draw_tux_text_ex(TUX_GREAT, (char *)event.user.data1, 0, (int)(intptr_t) event.user.data2); //EP added (intptr_t) to avoid warning on x64 } } else @@ -6193,10 +5918,10 @@ static void mainloop(void) if (event.user.data1 != NULL) { - if ((int) (intptr_t) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... *///EP added (intptr_t) to avoid warning on x64 + if ((int)(intptr_t) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... *///EP added (intptr_t) to avoid warning on x64 { - if (!mute && stamp_data[stamp_group][(int) (intptr_t) event.user.data1]->sdesc != NULL) //EP added (intptr_t) to avoid warning on x64 - Mix_PlayChannel(2, stamp_data[stamp_group][(int) (intptr_t) event.user.data1]->sdesc, //EP added (intptr_t) to avoid warning on x64 + if (!mute && stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc != NULL) //EP added (intptr_t) to avoid warning on x64 + Mix_PlayChannel(2, stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc, //EP added (intptr_t) to avoid warning on x64 0); } } @@ -6230,8 +5955,7 @@ static void mainloop(void) } /* Erase the xor drawed at click */ - else if (cur_tool == TOOL_STAMP && stamp_xored - && event.button.button < 4) + else if (cur_tool == TOOL_STAMP && stamp_xored && event.button.button < 4) { stamp_xor(canvas->w / 2, canvas->h / 2); stamp_xored = 0; @@ -6254,14 +5978,12 @@ static void mainloop(void) { if (stamp_tool_mode == STAMP_TOOL_MODE_PLACE) { - /* Updating the screen to draw the outlines in touchscreens where there could be touch without previous drag. */ - update_screen(old_x - (CUR_STAMP_W + 1) / 2 + r_canvas.x, - old_y - (CUR_STAMP_H + 1) / 2 + r_canvas.y, - old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, - old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); + /* Updating the screen to draw the outlines in touchscreens where there could be touch without previous drag. */ + update_screen(old_x - (CUR_STAMP_W + 1) / 2 + r_canvas.x, + old_y - (CUR_STAMP_H + 1) / 2 + r_canvas.y, + old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); - if (old_x >= 0 && old_y >= 0 && old_x <= r_canvas.w - && old_y <= r_canvas.h) + if (old_x >= 0 && old_y >= 0 && old_x <= r_canvas.w && old_y <= r_canvas.h) { if (!no_stamp_rotation && stamp_rotation_ctrl) { @@ -6290,19 +6012,16 @@ static void mainloop(void) stamp_xor_line_old_y = STAMP_XOR_LINE_UNSET; #endif - snprintf(angle_tool_text, sizeof(angle_tool_text), - gettext(TIP_STAMPS_ROTATING), 0); + snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_STAMPS_ROTATING), 0); draw_tux_text(TUX_GREAT, angle_tool_text, 1); } else { /* Draw a stamp! */ rec_undo_buffer(); - playsound(screen, 1, SND_STAMP, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_STAMP, 1, event.button.x, SNDDIST_NEAR); stamp_draw(old_x, old_y, 0); - reset_stamps(&stamp_xored_rt, &old_x, &old_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &old_x, &old_y, &stamp_tool_mode); draw_tux_text(TUX_GREAT, great_str(), 1); @@ -6310,11 +6029,8 @@ static void mainloop(void) control_drawtext_timer(1000, stamp_data[stamp_group][cur_stamp - [stamp_group]]-> - stxt, - stamp_data[stamp_group][cur_stamp - [stamp_group]]-> - locale_text); + [stamp_group]]->stxt, + stamp_data[stamp_group][cur_stamp[stamp_group]]->locale_text); } } } @@ -6323,54 +6039,42 @@ static void mainloop(void) /* Draw a stamp (finishing rotation step)! */ rec_undo_buffer(); playsound(screen, 1, SND_STAMP, 1, stamp_place_x, SNDDIST_NEAR); - int stamp_angle_rotation = - 360 - stamp_rotation(stamp_place_x, stamp_place_y, old_x, - old_y); + int stamp_angle_rotation = 360 - stamp_rotation(stamp_place_x, stamp_place_y, old_x, + old_y); stamp_draw(stamp_place_x, stamp_place_y, stamp_angle_rotation); draw_tux_text(TUX_GREAT, great_str(), 1); - reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, - &stamp_tool_mode); + reset_stamps(&stamp_xored_rt, &stamp_place_x, &stamp_place_y, &stamp_tool_mode); /* FIXME: Make delay configurable: */ control_drawtext_timer(1000, stamp_data[stamp_group][cur_stamp - [stamp_group]]-> - stxt, - stamp_data[stamp_group][cur_stamp - [stamp_group]]-> - locale_text); + [stamp_group]]->stxt, + stamp_data[stamp_group][cur_stamp[stamp_group]]->locale_text); } } else if (cur_tool == TOOL_LINES) { - if (!mouseaccessibility - || (mouseaccessibility && !emulate_button_pressed)) + if (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed)) { /* (Arbitrarily large, so we draw once now) */ reset_brush_counter(); - brush_draw(line_start_x, line_start_y, - event.button.x - r_canvas.x, - event.button.y - r_canvas.y, 1); + brush_draw(line_start_x, line_start_y, event.button.x - r_canvas.x, event.button.y - r_canvas.y, 1); brush_draw(event.button.x - r_canvas.x, - event.button.y - r_canvas.y, - event.button.x - r_canvas.x, - event.button.y - r_canvas.y, 1); + event.button.y - r_canvas.y, event.button.x - r_canvas.x, event.button.y - r_canvas.y, 1); - playsound(screen, 1, SND_LINE_END, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_END, 1, event.button.x, SNDDIST_NEAR); draw_tux_text(TUX_GREAT, tool_tips[TOOL_LINES], 1); } } else if (cur_tool == TOOL_SHAPES) { - if (!mouseaccessibility - || (mouseaccessibility && !emulate_button_pressed)) + if (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed)) { if (shape_tool_mode == SHAPE_TOOL_MODE_STRETCH) { @@ -6379,10 +6083,13 @@ static void mainloop(void) shape_current_x = event.button.x - r_canvas.x; shape_current_y = event.button.y - r_canvas.y; - if (shape_mode == SHAPEMODE_CENTER) { + if (shape_mode == SHAPEMODE_CENTER) + { shape_ctr_x = shape_start_x; shape_ctr_y = shape_start_y; - } else { + } + else + { shape_ctr_x = shape_start_x + (shape_current_x - shape_start_x) / 2; shape_ctr_y = shape_start_y + (shape_current_y - shape_start_y) / 2; } @@ -6394,31 +6101,25 @@ static void mainloop(void) shape_radius = sqrt((shape_start_x - shape_current_x) * (shape_start_x - shape_current_x) - + (shape_start_y - - shape_current_y) * (shape_start_y - - shape_current_y)); + + (shape_start_y - shape_current_y) * (shape_start_y - shape_current_y)); - SDL_WarpMouse(shape_ctr_x + (shape_current_x - shape_ctr_x) * 1.05 + r_canvas.x, shape_ctr_y + r_canvas.y); + SDL_WarpMouse(shape_ctr_x + (shape_current_x - shape_ctr_x) * 1.05 + r_canvas.x, + shape_ctr_y + r_canvas.y); do_setcursor(cursor_rotate); /* Erase stretchy XOR: */ - if (abs(shape_start_x - shape_current_x) > 15 - || abs(shape_start_y - shape_current_y) > 15) - do_shape(shape_start_x, shape_start_y, old_x, old_y, 0, - 0); + if (abs(shape_start_x - shape_current_x) > 15 || abs(shape_start_y - shape_current_y) > 15) + do_shape(shape_start_x, shape_start_y, old_x, old_y, 0, 0); /* Make an initial rotation XOR to be erased: */ do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, - shape_rotation(shape_ctr_x, shape_ctr_y, - shape_current_x, shape_current_y), - 0); + shape_rotation(shape_ctr_x, shape_ctr_y, shape_current_x, shape_current_y), 0); - playsound(screen, 1, SND_LINE_START, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_START, 1, event.button.x, SNDDIST_NEAR); draw_tux_text(TUX_BORED, TIP_SHAPE_NEXT, 1); @@ -6431,39 +6132,29 @@ static void mainloop(void) reset_brush_counter(); - playsound(screen, 1, SND_LINE_END, 1, event.button.x, - SNDDIST_NEAR); - do_shape(shape_start_x, shape_start_y, shape_current_x, - shape_current_y, 0, 1); + playsound(screen, 1, SND_LINE_END, 1, event.button.x, SNDDIST_NEAR); + do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, 0, 1); SDL_Flip(screen); shape_tool_mode = SHAPE_TOOL_MODE_DONE; draw_tux_text(TUX_GREAT, - shape_tool_tips[simple_shapes ? - SHAPE_COMPLEXITY_SIMPLE : - SHAPE_COMPLEXITY_NORMAL], 1); + shape_tool_tips[simple_shapes ? SHAPE_COMPLEXITY_SIMPLE : SHAPE_COMPLEXITY_NORMAL], 1); } } else if (shape_tool_mode == SHAPE_TOOL_MODE_ROTATE) { reset_brush_counter(); - playsound(screen, 1, SND_LINE_END, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_LINE_END, 1, event.button.x, SNDDIST_NEAR); do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, shape_rotation(shape_ctr_x, shape_ctr_y, - event.button.x - - r_canvas.x, - event.button.y - - r_canvas.y), 1); + event.button.x - r_canvas.x, event.button.y - r_canvas.y), 1); shape_tool_mode = SHAPE_TOOL_MODE_DONE; draw_tux_text(TUX_GREAT, - shape_tool_tips[simple_shapes ? - SHAPE_COMPLEXITY_SIMPLE : - SHAPE_COMPLEXITY_NORMAL], 1); + shape_tool_tips[simple_shapes ? SHAPE_COMPLEXITY_SIMPLE : SHAPE_COMPLEXITY_NORMAL], 1); /* FIXME: Do something less intensive! */ @@ -6475,9 +6166,7 @@ static void mainloop(void) && (magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT || magics[magic_group][cur_magic[magic_group]].mode == - MODE_ONECLICK - || magics[magic_group][cur_magic[magic_group]].mode == - MODE_PAINT_WITH_PREVIEW)) + MODE_ONECLICK || magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT_WITH_PREVIEW)) { int grp; int cur; @@ -6485,8 +6174,7 @@ static void mainloop(void) grp = magic_group; cur = cur_magic[grp]; - if (!mouseaccessibility - || (mouseaccessibility && !emulate_button_pressed)) + if (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed)) { int undo_ctr; SDL_Surface *last; @@ -6505,23 +6193,17 @@ static void mainloop(void) update_rect.w = 0; update_rect.h = 0; - magic_funcs[magics[grp][cur].handle_idx]. - release(magic_api_struct, magics[grp][cur].idx, canvas, last, - old_x, old_y, &update_rect); + magic_funcs[magics[grp][cur].handle_idx].release(magic_api_struct, magics[grp][cur].idx, canvas, last, + old_x, old_y, &update_rect); - draw_tux_text(TUX_GREAT, - magics[grp][cur].tip[magic_modeint - (magics[grp][cur].mode)], 1); + draw_tux_text(TUX_GREAT, magics[grp][cur].tip[magic_modeint(magics[grp][cur].mode)], 1); - update_canvas(update_rect.x, update_rect.y, - update_rect.x + update_rect.w, - update_rect.y + update_rect.h); + update_canvas(update_rect.x, update_rect.y, update_rect.x + update_rect.w, update_rect.y + update_rect.h); } } else if (onscreen_keyboard && (cur_tool == TOOL_TEXT - || (cur_tool == TOOL_LABEL && cur_label != LABEL_SELECT - && cur_label != LABEL_APPLY))) + || (cur_tool == TOOL_LABEL && cur_label != LABEL_SELECT && cur_label != LABEL_APPLY))) { if (onscreen_keyboard && kbd) { @@ -6580,18 +6262,14 @@ static void mainloop(void) } else if (event.button.y > r_tools.y + r_tools.h - button_h / 2) { - if (tool_scroll < - NUM_TOOLS - buttons_tall * gd_tools.cols + gd_tools.cols) + if (tool_scroll < NUM_TOOLS - buttons_tall * gd_tools.cols + gd_tools.cols) do_setcursor(cursor_down); else do_setcursor(cursor_arrow); } else if (tool_avail[((event.button.x - r_tools.x) / button_w) + - ((event.button.y - - r_tools.y - - button_h / 2) / button_h) * gd_tools.cols + - tool_scroll]) + ((event.button.y - r_tools.y - button_h / 2) / button_h) * gd_tools.cols + tool_scroll]) { do_setcursor(cursor_hand); } @@ -6605,8 +6283,7 @@ static void mainloop(void) else { if (tool_avail[((event.button.x - r_tools.x) / button_w) + - ((event.button.y - - r_tools.y) / button_h) * gd_tools.cols]) + ((event.button.y - r_tools.y) / button_h) * gd_tools.cols]) { do_setcursor(cursor_hand); } @@ -6623,9 +6300,7 @@ static void mainloop(void) if (cur_tool == TOOL_STAMP && use_sound && !mute && ((GRIDHIT_GD(r_sfx, gd_sfx) == 0 && !stamp_data[stamp_group][cur_stamp[stamp_group]]->no_sound) || - (GRIDHIT_GD(r_sfx, gd_sfx) == 1 && - !stamp_data[stamp_group][cur_stamp - [stamp_group]]->no_descsound))) + (GRIDHIT_GD(r_sfx, gd_sfx) == 1 && !stamp_data[stamp_group][cur_stamp[stamp_group]]->no_descsound))) { do_setcursor(cursor_hand); } @@ -6681,12 +6356,10 @@ static void mainloop(void) control_rows = calc_magic_control_rows(); if (cur_tool == TOOL_SHAPES && !disable_shape_controls) control_rows = 1; - if ((cur_tool == TOOL_BRUSH || cur_tool == TOOL_LINES) - && !disable_brushspacing) + if ((cur_tool == TOOL_BRUSH || cur_tool == TOOL_LINES) && !disable_brushspacing) control_rows = 1; - num_places = - buttons_tall * gd_toolopt.cols - control_rows * gd_toolopt.cols; + num_places = buttons_tall * gd_toolopt.cols - control_rows * gd_toolopt.cols; if (num_things > num_places) { @@ -6705,8 +6378,7 @@ static void mainloop(void) (button_h * (num_places / gd_toolopt.cols) + r_ttoolopt.h + img_scroll_up->h) && event.button.y <= - (button_h * (num_places / gd_toolopt.cols) + - r_ttoolopt.h + img_scroll_up->h + img_scroll_up->h)) + (button_h * (num_places / gd_toolopt.cols) + r_ttoolopt.h + img_scroll_up->h + img_scroll_up->h)) { /* Down button; is it available? */ @@ -6723,10 +6395,7 @@ static void mainloop(void) which = ((event.button.y - r_ttoolopt.h - - img_scroll_up->h) / button_h) * 2 + (event.button.x - - (WINDOW_WIDTH - - r_ttoolopt.w)) / - button_w; + img_scroll_up->h) / button_h) * 2 + (event.button.x - (WINDOW_WIDTH - r_ttoolopt.w)) / button_w; if (which < num_things) do_setcursor(cursor_hand); @@ -6758,12 +6427,18 @@ static void mainloop(void) do_setcursor(cursor_brush); else if (cur_tool == TOOL_STAMP) { - if (stamp_tool_mode != STAMP_TOOL_MODE_ROTATE) { + if (stamp_tool_mode != STAMP_TOOL_MODE_ROTATE) + { do_setcursor(cursor_tiny); - } else { - if (stamp_will_rotate(new_x, new_y, stamp_place_x, stamp_place_y)) { + } + else + { + if (stamp_will_rotate(new_x, new_y, stamp_place_x, stamp_place_y)) + { do_setcursor(cursor_rotate); - } else { + } + else + { do_setcursor(cursor_hand); } } @@ -6795,9 +6470,7 @@ static void mainloop(void) } else if (cur_label == LABEL_SELECT || cur_label == LABEL_APPLY) { - if (search_label_list - (¤t_label_node, event.button.x - r_ttools.w, - event.button.y, 1)) + if (search_label_list(¤t_label_node, event.button.x - r_ttools.w, event.button.y, 1)) do_setcursor(cursor_hand); else do_setcursor(cursor_arrow); @@ -6822,8 +6495,7 @@ static void mainloop(void) brush_draw(old_x, old_y, new_x, new_y, 1); - playsound(screen, 0, paintsound(img_cur_brush_w), 0, - event.button.x, SNDDIST_NEAR); + playsound(screen, 0, paintsound(img_cur_brush_w), 0, event.button.x, SNDDIST_NEAR); } else if (cur_tool == TOOL_LINES) { @@ -6845,20 +6517,15 @@ static void mainloop(void) angle += 360.0; #ifndef __ANDROID__ - update_screen(line_start_x + r_canvas.x, - line_start_y + r_canvas.y, old_x + r_canvas.x, - old_y + r_canvas.y); - update_screen(line_start_x + r_canvas.x, - line_start_y + r_canvas.y, new_x + r_canvas.x, - new_y + r_canvas.y); + update_screen(line_start_x + r_canvas.x, line_start_y + r_canvas.y, old_x + r_canvas.x, old_y + r_canvas.y); + update_screen(line_start_x + r_canvas.x, line_start_y + r_canvas.y, new_x + r_canvas.x, new_y + r_canvas.y); update_screen(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); #else /* Anyway SDL_UpdateRect() backward compatibility function refreshes all the screen on Android */ SDL_UpdateRect(screen, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); #endif - snprintf(angle_tool_text, sizeof(angle_tool_text), - gettext(TIP_LINE_MOVING), floor(angle)); + snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_LINE_MOVING), floor(angle)); draw_tux_text(TUX_BORED, angle_tool_text, 1); } else if (cur_tool == TOOL_SHAPES) @@ -6888,9 +6555,7 @@ static void mainloop(void) && (magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT || magics[magic_group][cur_magic[magic_group]].mode == - MODE_ONECLICK - || magics[magic_group][cur_magic[magic_group]].mode == - MODE_PAINT_WITH_PREVIEW)) + MODE_ONECLICK || magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT_WITH_PREVIEW)) { int undo_ctr; SDL_Surface *last; @@ -6910,16 +6575,12 @@ static void mainloop(void) update_rect.h = 0; magic_funcs[magics[magic_group] - [cur_magic[magic_group]]. - handle_idx].drag(magic_api_struct, - magics[magic_group][cur_magic - [magic_group]]. - idx, canvas, last, old_x, old_y, - new_x, new_y, &update_rect); + [cur_magic[magic_group]].handle_idx].drag(magic_api_struct, + magics[magic_group][cur_magic + [magic_group]].idx, canvas, last, + old_x, old_y, new_x, new_y, &update_rect); - update_canvas(update_rect.x, update_rect.y, - update_rect.x + update_rect.w, - update_rect.y + update_rect.h); + update_canvas(update_rect.x, update_rect.y, update_rect.x + update_rect.w, update_rect.y + update_rect.h); } else if (cur_tool == TOOL_ERASER) { @@ -6938,12 +6599,10 @@ static void mainloop(void) else { /* Square eraser */ - rect_xor(new_x - sz / 2, new_y - sz / 2, new_x + sz / 2, - new_y + sz / 2); + rect_xor(new_x - sz / 2, new_y - sz / 2, new_x + sz / 2, new_y + sz / 2); } } - else if (cur_tool == TOOL_FILL && cur_fill == FILL_GRADIENT_LINEAR - && fill_drag_started) + else if (cur_tool == TOOL_FILL && cur_fill == FILL_GRADIENT_LINEAR && fill_drag_started) { Uint32 draw_color; int undo_ctr; @@ -6959,15 +6618,12 @@ static void mainloop(void) /* Pushing button and moving: Update the gradient: */ draw_color = SDL_MapRGB(canvas->format, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2]); + color_hexes[cur_color][0], color_hexes[cur_color][1], color_hexes[cur_color][2]); draw_linear_gradient(canvas, last, sim_flood_x1, sim_flood_y1, sim_flood_x2, sim_flood_y2, fill_x, fill_y, new_x, new_y, draw_color, sim_flood_touched); - update_canvas(sim_flood_x1, sim_flood_y1, sim_flood_x2, - sim_flood_y2); + update_canvas(sim_flood_x1, sim_flood_y1, sim_flood_x2, sim_flood_y2); } else if (cur_tool == TOOL_FILL && cur_fill == FILL_BRUSH) { @@ -6977,14 +6633,11 @@ static void mainloop(void) /* Pushing button and moving: Paint more within the fill area: */ draw_color = SDL_MapRGB(canvas->format, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2]); + color_hexes[cur_color][0], color_hexes[cur_color][1], color_hexes[cur_color][2]); draw_brush_fill(canvas, sim_flood_x1, sim_flood_y1, sim_flood_x2, sim_flood_y2, old_x, old_y, new_x, new_y, - draw_color, sim_flood_touched, &x1, &y1, &x2, - &y2); + draw_color, sim_flood_touched, &x1, &y1, &x2, &y2); update_canvas(x1, y1, x2, y2); } @@ -6993,8 +6646,7 @@ static void mainloop(void) if (cur_tool == TOOL_STAMP || ((cur_tool == TOOL_ERASER && !button_down) && - (!mouseaccessibility - || (mouseaccessibility && !emulate_button_pressed)))) + (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed)))) { int w = 0; int h = 0; @@ -7011,8 +6663,7 @@ static void mainloop(void) if (cur_eraser < NUM_ERASERS / 2) { w = (ERASER_MIN + - (((NUM_ERASERS / 2) - cur_eraser - 1) * - ((ERASER_MAX - ERASER_MIN) / ((NUM_ERASERS / 2) - 1)))); + (((NUM_ERASERS / 2) - cur_eraser - 1) * ((ERASER_MAX - ERASER_MIN) / ((NUM_ERASERS / 2) - 1)))); } else { @@ -7024,8 +6675,7 @@ static void mainloop(void) h = w; } - if (old_x >= 0 && old_x < r_canvas.w && old_y >= 0 - && old_y < r_canvas.h) + if (old_x >= 0 && old_x < r_canvas.w && old_y >= 0 && old_y < r_canvas.h) { if (cur_tool == TOOL_STAMP) { @@ -7037,8 +6687,10 @@ static void mainloop(void) #ifdef EXPERIMENT_STAMP_ROTATION_LINE /* Erase old stamp rotation angle XOR'd line */ /* FIXME: Needs also be erased in other situations! */ - if (stamp_xor_line_old_x != STAMP_XOR_LINE_UNSET && stamp_xor_line_old_y != STAMP_XOR_LINE_UNSET) { - if (stamp_will_rotate(stamp_place_x, stamp_place_y, stamp_xor_line_old_x, stamp_xor_line_old_y)) { + if (stamp_xor_line_old_x != STAMP_XOR_LINE_UNSET && stamp_xor_line_old_y != STAMP_XOR_LINE_UNSET) + { + if (stamp_will_rotate(stamp_place_x, stamp_place_y, stamp_xor_line_old_x, stamp_xor_line_old_y)) + { line_xor(stamp_place_x, stamp_place_y, stamp_xor_line_old_x, stamp_xor_line_old_y); } } @@ -7050,11 +6702,14 @@ static void mainloop(void) stamp_xor(stamp_place_x, stamp_place_y); #ifdef EXPERIMENT_STAMP_ROTATION_LINE /* Erase old stamp rotation angle XOR'd line */ - if (stamp_will_rotate(stamp_place_x, stamp_place_y, new_x, new_y)) { + if (stamp_will_rotate(stamp_place_x, stamp_place_y, new_x, new_y)) + { line_xor(stamp_place_x, stamp_place_y, new_x, new_y); stamp_xor_line_old_x = new_x; stamp_xor_line_old_y = new_y; - } else { + } + else + { stamp_xor_line_old_x = STAMP_XOR_LINE_UNSET; stamp_xor_line_old_y = STAMP_XOR_LINE_UNSET; } @@ -7063,8 +6718,7 @@ static void mainloop(void) #ifndef EXPERIMENT_STAMP_ROTATION_LINE /* The half of maximum size the stamp could have when rotating. */ int half_bigbox = - sqrt((CUR_STAMP_W + 1) * (CUR_STAMP_W + 1) + - (CUR_STAMP_H + 1) * (CUR_STAMP_H + 1)) / 2; + sqrt((CUR_STAMP_W + 1) * (CUR_STAMP_W + 1) + (CUR_STAMP_H + 1) * (CUR_STAMP_H + 1)) / 2; update_screen(min(min(new_x, old_x), stamp_place_x - half_bigbox) + r_canvas.x, min(min(new_y, old_y), stamp_place_y - half_bigbox) + r_canvas.y, max(max(new_x, old_x), stamp_place_x + half_bigbox) + r_canvas.x, @@ -7074,8 +6728,7 @@ static void mainloop(void) SDL_UpdateRect(screen, 0, 0, screen->w, screen->h); #endif - snprintf(angle_tool_text, sizeof(angle_tool_text), - gettext(TIP_STAMPS_ROTATING), deg); + snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_STAMPS_ROTATING), deg); draw_tux_text(TUX_GREAT, angle_tool_text, 1); } else if (stamp_xored_rt) @@ -7086,8 +6739,7 @@ static void mainloop(void) update_screen(old_x - (CUR_STAMP_W + 1) / 2 + r_canvas.x, old_y - (CUR_STAMP_H + 1) / 2 + r_canvas.y, - old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, - old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); + old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); } } else @@ -7100,18 +6752,14 @@ static void mainloop(void) else { /* Otherwise (square eraser) */ - rect_xor(old_x - w / 2, old_y - h / 2, old_x + w / 2, - old_y + h / 2); + rect_xor(old_x - w / 2, old_y - h / 2, old_x + w / 2, old_y + h / 2); } update_screen(old_x - w / 2 + r_canvas.x, - old_y - h / 2 + r_canvas.y, - old_x + w / 2 + r_canvas.x, - old_y + h / 2 + r_canvas.y); + old_y - h / 2 + r_canvas.y, old_x + w / 2 + r_canvas.x, old_y + h / 2 + r_canvas.y); } } - if (new_x >= 0 && new_x < r_canvas.w && new_y >= 0 - && new_y < r_canvas.h) + if (new_x >= 0 && new_x < r_canvas.w && new_y >= 0 && new_y < r_canvas.h) { if (cur_tool == TOOL_STAMP) { @@ -7123,8 +6771,7 @@ static void mainloop(void) } update_screen(old_x - (CUR_STAMP_W + 1) / 2 + r_canvas.x, old_y - (CUR_STAMP_H + 1) / 2 + r_canvas.y, - old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, - old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); + old_x + (CUR_STAMP_W + 1) / 2 + r_canvas.x, old_y + (CUR_STAMP_H + 1) / 2 + r_canvas.y); } else { @@ -7136,21 +6783,16 @@ static void mainloop(void) else { /* Otherwise (square eraser) */ - rect_xor(new_x - w / 2, new_y - h / 2, new_x + w / 2, - new_y + h / 2); + rect_xor(new_x - w / 2, new_y - h / 2, new_x + w / 2, new_y + h / 2); } update_screen(new_x - w / 2 + r_canvas.x, - new_y - h / 2 + r_canvas.y, - new_x + w / 2 + r_canvas.x, - new_y + h / 2 + r_canvas.y); + new_y - h / 2 + r_canvas.y, new_x + w / 2 + r_canvas.x, new_y + h / 2 + r_canvas.y); } } if (cur_tool == TOOL_STAMP && HIT(r_toolopt) - && event.motion.y > r_toolopt.h - && event.motion.state == SDL_PRESSED - && stamp_size_selector_clicked) + && event.motion.y > r_toolopt.h && event.motion.state == SDL_PRESSED && stamp_size_selector_clicked) { int control_sound = -1; int w, h; @@ -7164,18 +6806,17 @@ static void mainloop(void) w = CUR_STAMP_W; h = CUR_STAMP_H; - stamp_data[stamp_group][cur_stamp[stamp_group]]->size = - (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 - /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ - ) * (event.button.x - - (WINDOW_WIDTH - r_ttoolopt.w))) / r_toolopt.w) + + stamp_data[stamp_group][cur_stamp[stamp_group]]->size = (((MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1 + /* +1 to address lack of ability to get back to max default stamp size (SF Bug #1668235 -bjk 2011.01.08) */ + ) * (event.button.x - + (WINDOW_WIDTH - + r_ttoolopt.w))) / r_toolopt.w) + MIN_STAMP_SIZE; DEBUG_PRINTF("Old size = %d, Chose %0.4f, New size =%d\n", old_size, choice, stamp_data[stamp_group][cur_stamp[stamp_group]]->size); - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size != - old_size) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size != old_size) { if (stamp_xored) { @@ -7184,8 +6825,7 @@ static void mainloop(void) update_screen(canvas->w / 2 - (w + 1) / 2 + r_canvas.x, canvas->h / 2 - (h + 1) / 2 + r_canvas.y, - canvas->w / 2 + (w + 1) / 2 + r_canvas.x, - canvas->h / 2 + (h + 1) / 2 + r_canvas.y); + canvas->w / 2 + (w + 1) / 2 + r_canvas.x, canvas->h / 2 + (h + 1) / 2 + r_canvas.y); } update_stamp_xor(0); @@ -7196,22 +6836,17 @@ static void mainloop(void) canvas->h / 2 - (CUR_STAMP_H + 1) / 2 + r_canvas.y, canvas->w / 2 + (CUR_STAMP_W + 1) / 2 + - r_canvas.x, - canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + - r_canvas.y); + r_canvas.x, canvas->h / 2 + (CUR_STAMP_H + 1) / 2 + r_canvas.y); } - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size < - old_size) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size < old_size) control_sound = SND_SHRINK; - else if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size > - old_size) + else if (stamp_data[stamp_group][cur_stamp[stamp_group]]->size > old_size) control_sound = SND_GROW; if (control_sound) { - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); draw_stamps(); update_screen_rect(&r_toolopt); } @@ -7219,8 +6854,7 @@ static void mainloop(void) } else if (cur_tool == TOOL_SHAPES) { - if (shape_tool_mode == SHAPE_TOOL_MODE_STRETCH - && !shape_locked[cur_shape]) + if (shape_tool_mode == SHAPE_TOOL_MODE_STRETCH && !shape_locked[cur_shape]) { float aspect; int w, h; @@ -7232,9 +6866,9 @@ static void mainloop(void) if (w < 2 || h < 2) aspect = 0; else if (w > h) - aspect = (float) w / (float) h; + aspect = (float)w / (float)h; else - aspect = (float) h / (float) w; + aspect = (float)h / (float)w; if (aspect == 0 || aspect >= 100) { @@ -7242,8 +6876,7 @@ static void mainloop(void) } else { - snprintf(stretch_tool_text, sizeof(stretch_tool_text), - gettext(TIP_SHAPE_STRETCHING_UNLOCKED), aspect); + snprintf(stretch_tool_text, sizeof(stretch_tool_text), gettext(TIP_SHAPE_STRETCHING_UNLOCKED), aspect); draw_tux_text(TUX_BORED, stretch_tool_text, 1); } } @@ -7252,19 +6885,16 @@ static void mainloop(void) int deg; deg = shape_rotation(shape_ctr_x, shape_ctr_y, old_x, old_y); - do_shape(shape_start_x, shape_start_y, shape_current_x, - shape_current_y, deg, 0); + do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0); deg = shape_rotation(shape_ctr_x, shape_ctr_y, new_x, new_y); - do_shape(shape_start_x, shape_start_y, shape_current_x, - shape_current_y, deg, 0); + do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0); deg = -deg; if (deg < 0) deg += 360; - snprintf(angle_tool_text, sizeof(angle_tool_text), - gettext(TIP_SHAPE_ROTATING), deg); + snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_SHAPE_ROTATING), deg); draw_tux_text(TUX_BORED, angle_tool_text, 1); /* FIXME: Do something less intensive! */ @@ -7279,17 +6909,14 @@ static void mainloop(void) } } - if (cur_tool == TOOL_TEXT - || (cur_tool == TOOL_LABEL && cur_label != LABEL_SELECT - && cur_label != LABEL_APPLY)) + if (cur_tool == TOOL_TEXT || (cur_tool == TOOL_LABEL && cur_label != LABEL_SELECT && cur_label != LABEL_APPLY)) { /* if (onscreen_keyboard) */ /* osk_clicked(kbd, old_x, old_y); */ /* on_screen_keyboardd(); */ cur_cursor_blink = SDL_GetTicks(); - if (cursor_x != -1 && cursor_y != -1 - && cur_cursor_blink > last_cursor_blink + CURSOR_BLINK_SPEED) + if (cursor_x != -1 && cursor_y != -1 && cur_cursor_blink > last_cursor_blink + CURSOR_BLINK_SPEED) { last_cursor_blink = SDL_GetTicks(); draw_blinking_cursor(); @@ -7305,8 +6932,7 @@ static void mainloop(void) } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); @@ -7343,14 +6969,12 @@ static void draw_blinking_cursor(void) cur_toggle_count++; line_xor(cursor_x + cursor_textwidth, cursor_y, - cursor_x + cursor_textwidth, - cursor_y + TuxPaint_Font_FontHeight(getfonthandle(cur_font))); + cursor_x + cursor_textwidth, cursor_y + TuxPaint_Font_FontHeight(getfonthandle(cur_font))); update_screen(cursor_x + r_canvas.x + cursor_textwidth, cursor_y + r_canvas.y, cursor_x + r_canvas.x + cursor_textwidth, - cursor_y + r_canvas.y + - TuxPaint_Font_FontHeight(getfonthandle(cur_font))); + cursor_y + r_canvas.y + TuxPaint_Font_FontHeight(getfonthandle(cur_font))); } /** @@ -7414,7 +7038,7 @@ static void brush_draw(int x1, int y1, int x2, int y2, int update) if (dx != 0) { - m = ((float) dy) / ((float) dx); + m = ((float)dy) / ((float)dx); b = y1 - m * x1; if (x2 >= x1) @@ -7506,8 +7130,7 @@ void reset_brush_counter(void) * @param direction BRUSH_DIRECTION_... being drawn (for compass direction brushes) * @param rotation angle being drawn (for brushes which may rotate at any angle (0-360 degrees)) */ -static void blit_brush(int x, int y, int direction, double rotation, int *w, - int *h) +static void blit_brush(int x, int y, int direction, double rotation, int *w, int *h) { SDL_Rect src, dest; @@ -7540,39 +7163,33 @@ static void blit_brush(int x, int y, int direction, double rotation, int *w, if (img_cur_brush_directional) { if (direction == BRUSH_DIRECTION_UP_LEFT || - direction == BRUSH_DIRECTION_UP - || direction == BRUSH_DIRECTION_UP_RIGHT) + direction == BRUSH_DIRECTION_UP || direction == BRUSH_DIRECTION_UP_RIGHT) { src.y = 0; } else if (direction == BRUSH_DIRECTION_LEFT || - direction == BRUSH_DIRECTION_NONE - || direction == BRUSH_DIRECTION_RIGHT) + direction == BRUSH_DIRECTION_NONE || direction == BRUSH_DIRECTION_RIGHT) { src.y = img_cur_brush_h; } else if (direction == BRUSH_DIRECTION_DOWN_LEFT || - direction == BRUSH_DIRECTION_DOWN - || direction == BRUSH_DIRECTION_DOWN_RIGHT) + direction == BRUSH_DIRECTION_DOWN || direction == BRUSH_DIRECTION_DOWN_RIGHT) { src.y = img_cur_brush_h << 1; } if (direction == BRUSH_DIRECTION_UP_LEFT || - direction == BRUSH_DIRECTION_LEFT - || direction == BRUSH_DIRECTION_DOWN_LEFT) + direction == BRUSH_DIRECTION_LEFT || direction == BRUSH_DIRECTION_DOWN_LEFT) { src.x = brush_frame * img_cur_brush_frame_w; } else if (direction == BRUSH_DIRECTION_UP || - direction == BRUSH_DIRECTION_NONE - || direction == BRUSH_DIRECTION_DOWN) + direction == BRUSH_DIRECTION_NONE || direction == BRUSH_DIRECTION_DOWN) { src.x = brush_frame * img_cur_brush_frame_w + img_cur_brush_w; } else if (direction == BRUSH_DIRECTION_UP_RIGHT || - direction == BRUSH_DIRECTION_RIGHT - || direction == BRUSH_DIRECTION_DOWN_RIGHT) + direction == BRUSH_DIRECTION_RIGHT || direction == BRUSH_DIRECTION_DOWN_RIGHT) { src.x = brush_frame * img_cur_brush_frame_w + (img_cur_brush_w << 1); } @@ -7605,22 +7222,19 @@ static void blit_brush(int x, int y, int direction, double rotation, int *w, img_cur_brush->format->BitsPerPixel, img_cur_brush->format->Rmask, img_cur_brush->format->Gmask, - img_cur_brush->format->Bmask, - img_cur_brush->format->Amask); + img_cur_brush->format->Bmask, img_cur_brush->format->Amask); if (brush_frame_surf != NULL) { /* 2021/09/28 SDL(2)_gfxBlitRGBA() is not available in the SDL2_gfx library, using plain SDL_BlitSurface() instead. Pere SDL_gfxBlitRGBA(img_cur_brush, &src, brush_frame_surf, NULL); */ SDL_BlitSurface(img_cur_brush, &src, brush_frame_surf, NULL); - rotated_brush = - rotozoomSurface(brush_frame_surf, rotation, 1.0, SMOOTHING_ON); + rotated_brush = rotozoomSurface(brush_frame_surf, rotation, 1.0, SMOOTHING_ON); SDL_FreeSurface(brush_frame_surf); } } else { - rotated_brush = - rotozoomSurface(img_cur_brush, rotation, 1.0, SMOOTHING_ON); + rotated_brush = rotozoomSurface(img_cur_brush, rotation, 1.0, SMOOTHING_ON); } if (rotated_brush != NULL) @@ -7695,9 +7309,7 @@ static void fill_multichan(multichan * mc, double *up, double *vp) fract = 1.0 / (X + 15.0 * Y + 3.0 * Z); u_prime = 4.0 * X * fract; v_prime = 9.0 * Y * fract; - mc->L = - (Y_norm > 0.008856) ? 116.0 * pow(Y_norm, - 1.0 / 3.0) - 16.0 : 903.3 * Y_norm; + mc->L = (Y_norm > 0.008856) ? 116.0 * pow(Y_norm, 1.0 / 3.0) - 16.0 : 903.3 * Y_norm; u = 13.0 * mc->L * (u_prime - u0_prime); v = 13.0 * mc->L * (v_prime - v0_prime); @@ -7720,8 +7332,7 @@ static double tint_part_1(multichan * work, SDL_Surface * in) double v_total = 0; double u, v; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[in->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[in->format->BytesPerPixel]; SDL_LockSurface(in); @@ -7732,8 +7343,7 @@ static double tint_part_1(multichan * work, SDL_Surface * in) multichan *mc = work + yy * in->w + xx; /* put pixels into a more tolerable form */ - SDL_GetRGBA(getpixel(in, xx, yy), in->format, &mc->or, &mc->og, &mc->ob, - &mc->alpha); + SDL_GetRGBA(getpixel(in, xx, yy), in->format, &mc->or, &mc->og, &mc->ob, &mc->alpha); fill_multichan(mc, &u, &v); @@ -7749,8 +7359,7 @@ static double tint_part_1(multichan * work, SDL_Surface * in) SDL_UnlockSurface(in); #ifdef DEBUG - fprintf(stderr, "u_total=%f\nv_total=%f\natan2()=%f\n", u_total, v_total, - atan2(u_total, v_total)); + fprintf(stderr, "u_total=%f\nv_total=%f\natan2()=%f\n", u_total, v_total, atan2(u_total, v_total)); #endif return atan2(u_total, v_total); @@ -7760,8 +7369,7 @@ static double tint_part_1(multichan * work, SDL_Surface * in) /** * FIXME */ -static void change_colors(SDL_Surface * out, multichan * work, - double hue_range, multichan * key_color_ptr) +static void change_colors(SDL_Surface * out, multichan * work, double hue_range, multichan * key_color_ptr) { double lower_hue_1, upper_hue_1, lower_hue_2, upper_hue_2; int xx, yy; @@ -7817,11 +7425,9 @@ static void change_colors(SDL_Surface * out, multichan * work, /* if not in the first range, and not in the second range, skip this one (really should alpha-blend as a function of hue angle difference) */ - if ((oldhue < lower_hue_1 || oldhue > upper_hue_1) - && (oldhue < lower_hue_2 || oldhue > upper_hue_2)) + if ((oldhue < lower_hue_1 || oldhue > upper_hue_1) && (oldhue < lower_hue_2 || oldhue > upper_hue_2)) { - putpixel(out, xx, yy, - SDL_MapRGBA(out->format, mc->or, mc->og, mc->ob, mc->alpha)); + putpixel(out, xx, yy, SDL_MapRGBA(out->format, mc->or, mc->og, mc->ob, mc->alpha)); continue; } @@ -7843,9 +7449,7 @@ static void change_colors(SDL_Surface * out, multichan * work, /* Luv to XYZ */ u_prime = u / (13.0 * L) + u0_prime; v_prime = v / (13.0 * L) + v0_prime; - Y = - (L > 7.99959199307) ? Y0 * pow((L + 16.0) / 116.0, - 3.0) : Y0 * L / 903.3; + Y = (L > 7.99959199307) ? Y0 * pow((L + 16.0) / 116.0, 3.0) : Y0 * L / 903.3; X = 2.25 * Y * u_prime / v_prime; Z = (3.0 * Y - 0.75 * Y * u_prime) / v_prime - 5.0 * Y; @@ -7856,16 +7460,14 @@ static void change_colors(SDL_Surface * out, multichan * work, /* If it is out of gamut, try to de-saturate it a few times before truncating. (the linear_to_sRGB function will truncate) */ - if ((r <= -0.5 || g <= -0.5 || b <= -0.5 || r >= 255.5 || g >= 255.5 - || b >= 255.5) && tries--) + if ((r <= -0.5 || g <= -0.5 || b <= -0.5 || r >= 255.5 || g >= 255.5 || b >= 255.5) && tries--) { newsat *= 0.8; goto trysat; } putpixel(out, xx, yy, - SDL_MapRGBA(out->format, linear_to_sRGB(r), linear_to_sRGB(g), - linear_to_sRGB(b), mc->alpha)); + SDL_MapRGBA(out->format, linear_to_sRGB(r), linear_to_sRGB(g), linear_to_sRGB(b), mc->alpha)); } } SDL_UnlockSurface(out); @@ -7875,8 +7477,7 @@ static void change_colors(SDL_Surface * out, multichan * work, /** * FIXME */ -static multichan *find_most_saturated(double initial_hue, multichan * work, - unsigned num, double *hue_range_ptr) +static multichan *find_most_saturated(double initial_hue, multichan * work, unsigned num, double *hue_range_ptr) { /* find the most saturated pixel near the initial hue guess */ multichan *key_color_ptr = NULL; @@ -7926,8 +7527,7 @@ hue_range_retry:; mc = work + i; /* if not in the first range, and not in the second range, skip this one */ - if ((mc->hue < lower_hue_1 || mc->hue > upper_hue_1) - && (mc->hue < lower_hue_2 || mc->hue > upper_hue_2)) + if ((mc->hue < lower_hue_1 || mc->hue > upper_hue_1) && (mc->hue < lower_hue_2 || mc->hue > upper_hue_2)) continue; if (mc->sat > max_sat) @@ -7958,10 +7558,8 @@ static void vector_tint_surface(SDL_Surface * out, SDL_Surface * in) { int xx, yy; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[in->format->BytesPerPixel]; - void (*putpixel)(SDL_Surface *, int, int, Uint32) = - putpixels[out->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[in->format->BytesPerPixel]; + void (*putpixel)(SDL_Surface *, int, int, Uint32) = putpixels[out->format->BytesPerPixel]; double r = sRGB_to_linear_table[color_hexes[cur_color][0]]; double g = sRGB_to_linear_table[color_hexes[cur_color][1]]; @@ -7977,14 +7575,10 @@ static void vector_tint_surface(SDL_Surface * out, SDL_Surface * in) SDL_GetRGBA(getpixel(in, xx, yy), in->format, &r8, &g8, &b8, &a8); /* get the linear greyscale value */ - old = - sRGB_to_linear_table[r8] * 0.2126 + - sRGB_to_linear_table[g8] * 0.7152 + sRGB_to_linear_table[b8] * 0.0722; + old = sRGB_to_linear_table[r8] * 0.2126 + sRGB_to_linear_table[g8] * 0.7152 + sRGB_to_linear_table[b8] * 0.0722; putpixel(out, xx, yy, - SDL_MapRGBA(out->format, linear_to_sRGB(r * old), - linear_to_sRGB(g * old), linear_to_sRGB(b * old), - a8)); + SDL_MapRGBA(out->format, linear_to_sRGB(r * old), linear_to_sRGB(g * old), linear_to_sRGB(b * old), a8)); } } SDL_UnlockSurface(in); @@ -8015,10 +7609,9 @@ static void tint_surface(SDL_Surface * tmp_surf, SDL_Surface * surf_ptr) DEBUG_PRINTF("initial_hue = %f\n", initial_hue); - key_color_ptr = - find_most_saturated(initial_hue, work, width * height, &hue_range); + key_color_ptr = find_most_saturated(initial_hue, work, width * height, &hue_range); - DEBUG_PRINTF("key_color_ptr = %d\n", (int) (intptr_t) key_color_ptr); //EP added (intptr_t) to avoid warning on x64 + DEBUG_PRINTF("key_color_ptr = %d\n", (int)(intptr_t) key_color_ptr); //EP added (intptr_t) to avoid warning on x64 if (key_color_ptr) { @@ -8040,8 +7633,7 @@ static void tint_surface(SDL_Surface * tmp_surf, SDL_Surface * surf_ptr) /* Failed! Fall back: */ - fprintf(stderr, - "Falling back to tinter=vector, this should be in the *.dat file\n"); + fprintf(stderr, "Falling back to tinter=vector, this should be in the *.dat file\n"); vector_tint_surface(tmp_surf, surf_ptr); } @@ -8076,26 +7668,21 @@ static void stamp_draw(int x, int y, int stamp_angle_rotation) getpixel = getpixels[surf_ptr->format->BytesPerPixel]; /* Create a temp surface to play with: */ - if (stamp_colorable(cur_stamp[stamp_group]) - || stamp_tintable(cur_stamp[stamp_group])) + if (stamp_colorable(cur_stamp[stamp_group]) || stamp_tintable(cur_stamp[stamp_group])) { - amask = - ~(surf_ptr->format->Rmask | surf_ptr->format->Gmask | surf_ptr-> - format->Bmask); + amask = ~(surf_ptr->format->Rmask | surf_ptr->format->Gmask | surf_ptr->format->Bmask); tmp_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, surf_ptr->w, surf_ptr->h, surf_ptr->format->BitsPerPixel, - surf_ptr->format->Rmask, surf_ptr->format->Gmask, - surf_ptr->format->Bmask, amask); + surf_ptr->format->Rmask, surf_ptr->format->Gmask, surf_ptr->format->Bmask, amask); if (tmp_surf == NULL) { fprintf(stderr, "\nError: Can't render the colored stamp!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -8135,14 +7722,11 @@ static void stamp_draw(int x, int y, int stamp_angle_rotation) { for (xx = 0; xx < surf_ptr->w; xx++) { - SDL_GetRGBA(getpixel(surf_ptr, xx, yy), surf_ptr->format, &r, &g, - &b, &a); + SDL_GetRGBA(getpixel(surf_ptr, xx, yy), surf_ptr->format, &r, &g, &b, &a); putpixel(tmp_surf, xx, yy, SDL_MapRGBA(tmp_surf->format, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2], a)); + color_hexes[cur_color][0], color_hexes[cur_color][1], color_hexes[cur_color][2], a)); } } @@ -8152,8 +7736,7 @@ static void stamp_draw(int x, int y, int stamp_angle_rotation) else if (stamp_tintable(cur_stamp[stamp_group])) { /* Tintable */ - if (stamp_data[stamp_group][cur_stamp[stamp_group]]->tinter == - TINTER_VECTOR) + if (stamp_data[stamp_group][cur_stamp[stamp_group]]->tinter == TINTER_VECTOR) vector_tint_surface(tmp_surf, surf_ptr); else tint_surface(tmp_surf, surf_ptr); @@ -8175,8 +7758,7 @@ static void stamp_draw(int x, int y, int stamp_angle_rotation) /* Rotate the stamp (if no_stamp_rotation is not configured) */ if (stamp_angle_rotation) - tmp_surf = - rotozoomSurface(tmp_surf, stamp_angle_rotation, 1.0, SMOOTHING_ON); + tmp_surf = rotozoomSurface(tmp_surf, stamp_angle_rotation, 1.0, SMOOTHING_ON); /* Where it will go? */ base_x = x - (tmp_surf->w + 1) / 2; @@ -8190,8 +7772,7 @@ static void stamp_draw(int x, int y, int stamp_angle_rotation) update_canvas(x - (tmp_surf->w + 1) / 2, - y - (tmp_surf->h + 1) / 2, x + (tmp_surf->w + 1) / 2, - y + (tmp_surf->h + 1) / 2); + y - (tmp_surf->h + 1) / 2, x + (tmp_surf->w + 1) / 2, y + (tmp_surf->h + 1) / 2); /* Free the temporary surfaces */ @@ -8267,8 +7848,7 @@ void show_version(int details) printf("\nBuilt with these options:\n"); - printf(" SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, - SDL_PATCHLEVEL); + printf(" SDL version %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); /* Quality reductions: */ @@ -8279,19 +7859,15 @@ void show_version(int details) #endif #ifdef LOW_QUALITY_COLOR_SELECTOR - printf - (" Low Quality Color Selector enabled (LOW_QUALITY_COLOR_SELECTOR)\n"); + printf(" Low Quality Color Selector enabled (LOW_QUALITY_COLOR_SELECTOR)\n"); #else - printf - (" Hight Quality Color Selector enabled (not LOW_QUALITY_COLOR_SELECTOR)\n"); + printf(" Hight Quality Color Selector enabled (not LOW_QUALITY_COLOR_SELECTOR)\n"); #endif #ifdef LOW_QUALITY_STAMP_OUTLINE - printf - (" Low Quality Stamp Outline enabled (LOW_QUALITY_STAMP_OUTLINE)\n"); + printf(" Low Quality Stamp Outline enabled (LOW_QUALITY_STAMP_OUTLINE)\n"); #else - printf - (" Hight Quality Stamp Outline enabled (not LOW_QUALITY_STAMP_OUTLINE)\n"); + printf(" Hight Quality Stamp Outline enabled (not LOW_QUALITY_STAMP_OUTLINE)\n"); #endif #ifdef NO_PROMPT_SHADOWS @@ -8542,13 +8118,8 @@ static unsigned compute_default_scale_factor(double ratio) while (defsize > 0) { - double this_err = - good_log - - log(scaletable[defsize].numer / (double) scaletable[defsize].denom); - double next_err = - good_log - - log(scaletable[defsize - 1].numer / - (double) scaletable[defsize - 1].denom); + double this_err = good_log - log(scaletable[defsize].numer / (double)scaletable[defsize].denom); + double next_err = good_log - log(scaletable[defsize - 1].numer / (double)scaletable[defsize - 1].denom); if (fabs(next_err) > fabs(this_err)) break; @@ -8572,8 +8143,7 @@ static void loadbrush_callback(SDL_Surface * screen, __attribute__((unused)) SDL_Texture * texture, __attribute__((unused)) SDL_Renderer * renderer, const char *restrict const dir, - unsigned dirlen, tp_ftw_str * files, - unsigned i, const char *restrict const locale) + unsigned dirlen, tp_ftw_str * files, unsigned i, const char *restrict const locale) { FILE *fi; char buf[64]; @@ -8581,8 +8151,8 @@ static void loadbrush_callback(SDL_Surface * screen, int brush_w, brush_h; float scale; - (void) dirlen; - (void) locale; + (void)dirlen; + (void)locale; qsort(files, i, sizeof *files, compare_ftw_str); @@ -8600,21 +8170,13 @@ static void loadbrush_callback(SDL_Surface * screen, if (num_brushes == num_brushes_max) { num_brushes_max = num_brushes_max * 5 / 4 + 4; - img_brushes = - realloc(img_brushes, num_brushes_max * sizeof *img_brushes); - img_brushes_thumbs = - realloc(img_brushes_thumbs, - num_brushes_max * sizeof *img_brushes_thumbs); - brushes_frames = - realloc(brushes_frames, num_brushes_max * sizeof(int)); - brushes_directional = - realloc(brushes_directional, num_brushes_max * sizeof(short)); - brushes_rotate = - realloc(brushes_rotate, num_brushes_max * sizeof(short)); - brushes_spacing = - realloc(brushes_spacing, num_brushes_max * sizeof(int)); - brushes_spacing_default = - realloc(brushes_spacing_default, num_brushes_max * sizeof(int)); + img_brushes = realloc(img_brushes, num_brushes_max * sizeof *img_brushes); + img_brushes_thumbs = realloc(img_brushes_thumbs, num_brushes_max * sizeof *img_brushes_thumbs); + brushes_frames = realloc(brushes_frames, num_brushes_max * sizeof(int)); + brushes_directional = realloc(brushes_directional, num_brushes_max * sizeof(short)); + brushes_rotate = realloc(brushes_rotate, num_brushes_max * sizeof(short)); + brushes_spacing = realloc(brushes_spacing, num_brushes_max * sizeof(int)); + brushes_spacing_default = realloc(brushes_spacing_default, num_brushes_max * sizeof(int)); } img_brushes[num_brushes] = loadimage(fname); @@ -8668,26 +8230,22 @@ static void loadbrush_callback(SDL_Surface * screen, /* Generate thumbnail */ brush_w = - ((img_brushes[num_brushes]->w / abs(brushes_frames[num_brushes])) / - (brushes_directional[num_brushes] ? 3 : 1)); - brush_h = - (img_brushes[num_brushes]->h / - (brushes_directional[num_brushes] ? 3 : 1)); + ((img_brushes[num_brushes]->w / abs(brushes_frames[num_brushes])) / (brushes_directional[num_brushes] ? 3 : 1)); + brush_h = (img_brushes[num_brushes]->h / (brushes_directional[num_brushes] ? 3 : 1)); if (brush_w <= button_w && brush_h <= button_h) { - img_brushes_thumbs[num_brushes] = - duplicate_surface(img_brushes[num_brushes]); + img_brushes_thumbs[num_brushes] = duplicate_surface(img_brushes[num_brushes]); } else { if (brush_w > brush_h) { - scale = (float) ((float) button_w / (float) brush_w); + scale = (float)((float)button_w / (float)brush_w); } else { - scale = (float) ((float) button_h / (float) brush_h); + scale = (float)((float)button_h / (float)brush_h); } img_brushes_thumbs[num_brushes] = thumbnail2(img_brushes[num_brushes], img_brushes[num_brushes]->w * scale, img_brushes[num_brushes]->h * scale, 0, /* no need to ask to keep aspect; already kept */ @@ -8709,8 +8267,7 @@ static void loadbrush_callback(SDL_Surface * screen, /** * FIXME */ -static void load_brush_dir(SDL_Surface * screen, - const char *restrict const dir) +static void load_brush_dir(SDL_Surface * screen, const char *restrict const dir) { char buf[TP_FTW_PATHSIZE]; unsigned dirlen = strlen(dir); @@ -8804,8 +8361,7 @@ static unsigned default_stamp_size; /** * FIXME */ -static void loadstamp_finisher(stamp_type * sd, unsigned w, unsigned h, - double ratio) +static void loadstamp_finisher(stamp_type * sd, unsigned w, unsigned h, double ratio) { unsigned int upper = HARD_MAX_STAMP_SIZE; unsigned int underscanned_upper = HARD_MAX_STAMP_SIZE; @@ -9241,8 +8797,7 @@ static void get_stamp_thumb(stamp_type * sd, int process_sound) if (sd->thumb_mirrored_flipped == sd->flipped && sd->thumb_mirrored_flipped == sd->mirrored && - sd->mirrored == sd->thumb_mirrored - && sd->flipped == sd->thumb_flipped) + sd->mirrored == sd->thumb_mirrored && sd->flipped == sd->thumb_flipped) { /* It's already the way we want */ @@ -9418,6 +8973,7 @@ static void get_stamp_thumb(stamp_type * sd, int process_sound) h = 40; int ww = (40 * button_w) / ORIGINAL_BUTTON_SIZE; int hh = (40 * button_h) / ORIGINAL_BUTTON_SIZE; + if (bigimg) { w = bigimg->w; @@ -9488,10 +9044,9 @@ static void loadstamp_callback(SDL_Surface * screen, __attribute__((unused)) SDL_Texture * texture, __attribute__((unused)) SDL_Renderer * renderer, const char *restrict const dir, - unsigned dirlen, tp_ftw_str * files, - unsigned i, const char *restrict const locale) + unsigned dirlen, tp_ftw_str * files, unsigned i, const char *restrict const locale) { - (void) locale; + (void)locale; DEBUG_PRINTF("loadstamp_callback (%d): %s\n", i, dir); @@ -9536,7 +9091,7 @@ static void loadstamp_callback(SDL_Surface * screen, mirror_ext = "_mirror.png"; flip_ext = "_flip.png"; mirrorflip_ext = "_mirror_flip.png"; - dotext = (char *) strcasestr(files[i].str, ext); + dotext = (char *)strcasestr(files[i].str, ext); #ifndef NOSVG if (dotext == NULL) @@ -9545,7 +9100,7 @@ static void loadstamp_callback(SDL_Surface * screen, mirror_ext = "_mirror.svg"; flip_ext = "_flip.svg"; mirrorflip_ext = "_mirror_flip.svg"; - dotext = (char *) strcasestr(files[i].str, ext); + dotext = (char *)strcasestr(files[i].str, ext); } else { @@ -9579,30 +9134,22 @@ static void loadstamp_callback(SDL_Surface * screen, show_progress_bar(screen); if (dotext > files[i].str && !strcasecmp(dotext, ext) - && (dotext - files[i].str + 1 + dirlen < (int) (sizeof fname)) + && (dotext - files[i].str + 1 + dirlen < (int)(sizeof fname)) && !strcasestr(files[i].str, mirror_ext) - && !strcasestr(files[i].str, flip_ext) - && !strcasestr(files[i].str, mirrorflip_ext)) + && !strcasestr(files[i].str, flip_ext) && !strcasestr(files[i].str, mirrorflip_ext)) { safe_snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str); if (num_stamps[stamp_group] == max_stamps[stamp_group]) { max_stamps[stamp_group] = max_stamps[stamp_group] * 5 / 4 + 15; stamp_data[stamp_group] = realloc(stamp_data[stamp_group], - max_stamps[stamp_group] * - sizeof(*stamp_data[stamp_group])); + max_stamps[stamp_group] * sizeof(*stamp_data[stamp_group])); } stamp_data[stamp_group][num_stamps[stamp_group]] = calloc(1, sizeof *stamp_data[stamp_group][num_stamps[stamp_group]]); - stamp_data[stamp_group][num_stamps[stamp_group]]->stampname = - malloc(dotext - files[i].str + 1 + dirlen + 1); - memcpy(stamp_data[stamp_group][num_stamps[stamp_group]]->stampname, - fname, dotext - files[i].str + 1 + dirlen); - stamp_data[stamp_group][num_stamps[stamp_group]]->stampname[dotext - - files[i].str - + 1 + - dirlen] = - '\0'; + stamp_data[stamp_group][num_stamps[stamp_group]]->stampname = malloc(dotext - files[i].str + 1 + dirlen + 1); + memcpy(stamp_data[stamp_group][num_stamps[stamp_group]]->stampname, fname, dotext - files[i].str + 1 + dirlen); + stamp_data[stamp_group][num_stamps[stamp_group]]->stampname[dotext - files[i].str + 1 + dirlen] = '\0'; if (strcmp(ext, ".svg") == 0) { @@ -9663,9 +9210,7 @@ static void load_stamps(SDL_Surface * screen) if (num_stamps[0] == 0) { - fprintf(stderr, - "\nWarning: No stamps found in " DATA_PREFIX "stamps/\n" - "or %s\n\n", homedirdir); + fprintf(stderr, "\nWarning: No stamps found in " DATA_PREFIX "stamps/\n" "or %s\n\n", homedirdir); } num_stamp_groups = stamp_group + 1; @@ -9702,9 +9247,7 @@ int generate_fontconfig_cache_spinner(SDL_Surface * screen) while (SDL_PollEvent(&event) > 0) { if (event.type == SDL_QUIT || - (event.type == SDL_KEYDOWN - && (event.key.keysym.sym == SDLK_ESCAPE - || event.key.keysym.sym == SDLK_AC_BACK))) + (event.type == SDL_KEYDOWN && (event.key.keysym.sym == SDLK_ESCAPE || event.key.keysym.sym == SDLK_AC_BACK))) { fprintf(stderr, "Aborting!\n"); fflush(stdout); @@ -9808,47 +9351,53 @@ static SDL_Surface *do_render_button_label(const char *const label) DEBUG_PRINTF("do_render_button_label(\"%s\")\n", label); if (button_w <= ORIGINAL_BUTTON_SIZE) - { - DEBUG_PRINTF("Small font\n"); - myfont = small_font; - } + { + DEBUG_PRINTF("Small font\n"); + myfont = small_font; + } else if (button_w <= ORIGINAL_BUTTON_SIZE * 3) - { - DEBUG_PRINTF("Medium font\n"); - myfont = medium_font; - } + { + DEBUG_PRINTF("Medium font\n"); + myfont = medium_font; + } else - { - DEBUG_PRINTF("Large font\n"); - myfont = large_font; - } + { + DEBUG_PRINTF("Large font\n"); + myfont = large_font; + } if (need_own_font && strcmp(gettext(label), label)) - { - myfont = locale_font; - DEBUG_PRINTF("Need local font\n"); - } + { + myfont = locale_font; + DEBUG_PRINTF("Need local font\n"); + } tmp_surf1 = render_text(myfont, upstr, black); - if (tmp_surf1 == NULL) { + if (tmp_surf1 == NULL) + { fprintf(stderr, "Failed to render button '%s'!\n", upstr); exit(1); } height_mult = 1.0; - if (tmp_surf1->w >= button_w * 1.5) { + if (tmp_surf1->w >= button_w * 1.5) + { DEBUG_PRINTF("'%s' is very wide (%d) compared to button size (%d)\n", upstr, tmp_surf1->w, button_w); - if (strstr(upstr, " ") != NULL) { + if (strstr(upstr, " ") != NULL) + { int i, found = -1; - for (i = (strlen(upstr) * 3 / 4); i >= 0 && found == -1; i--) { - if (upstr[i] == ' ') { + for (i = (strlen(upstr) * 3 / 4); i >= 0 && found == -1; i--) + { + if (upstr[i] == ' ') + { found = i; } } - if (found != -1) { + if (found != -1) + { upstr[found] = '\n'; SDL_FreeSurface(tmp_surf1); @@ -9866,7 +9415,7 @@ static SDL_Surface *do_render_button_label(const char *const label) // FIXME: CROP LABELS #if 0 tmp_surf = crop_surface(tmp_surf1); - if(tmp_surf == NULL) + if (tmp_surf == NULL) return NULL; SDL_FreeSurface(tmp_surf1); @@ -9874,14 +9423,12 @@ static SDL_Surface *do_render_button_label(const char *const label) DEBUG_PRINTF("Rendered as: %d x %d\n", tmp_surf->w, tmp_surf->h); - want_h = (int) (18 * button_scale + button_label_y_nudge) * height_mult; + want_h = (int)(18 * button_scale + button_label_y_nudge) * height_mult; DEBUG_PRINTF(" button_w = %d -- min w = %d\n", button_w, min(button_w, tmp_surf->w)); DEBUG_PRINTF(" want_h = %d -- min h = %d\n", want_h, min(want_h, tmp_surf->h)); - surf = - thumbnail(tmp_surf, min(button_w, tmp_surf->w), - min(want_h, tmp_surf->h), 1 /* keep aspect! */); + surf = thumbnail(tmp_surf, min(button_w, tmp_surf->w), min(want_h, tmp_surf->h), 1 /* keep aspect! */ ); SDL_FreeSurface(tmp_surf); DEBUG_PRINTF("Resized to: %d x %d\n", surf->w, surf->h); @@ -9891,12 +9438,13 @@ static SDL_Surface *do_render_button_label(const char *const label) } #if 0 -static SDL_Surface * crop_surface(SDL_Surface * surf) { +static SDL_Surface *crop_surface(SDL_Surface * surf) +{ int top, bottom, left, right, x, y, w, h; Uint8 r, g, b, a, r1, g1, b1, a1; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[surf->format->BytesPerPixel]; - SDL_Surface * new_surf; + + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[surf->format->BytesPerPixel]; + SDL_Surface *new_surf; SDL_Rect src_rect; SDL_GetRGBA(getpixel(surf, 0, 0), surf->format, &r1, &g1, &b1, &a1); @@ -9906,10 +9454,13 @@ static SDL_Surface * crop_surface(SDL_Surface * surf) { left = surf->w - 1; right = 0; - for (y = 0; y < surf->h; y++) { - for (x = 0; x < surf->w; x++) { + for (y = 0; y < surf->h; y++) + { + for (x = 0; x < surf->w; x++) + { SDL_GetRGBA(getpixel(surf, x, y), surf->format, &r, &g, &b, &a); - if (r != r1 || g != g1 || b != b1 || a != a1) { + if (r != r1 || g != g1 || b != b1 || a != a1) + { if (y < top) top = y; if (x < left) @@ -9927,22 +9478,20 @@ static SDL_Surface * crop_surface(SDL_Surface * surf) { DEBUG_PRINTF("Cropping %d x %d to %d x %d, from (%d,%d)\n", surf->w, surf->h, w, h, left, top); - if ((top == 0 && bottom == surf->h - 1 && left == 0 && right == surf->w - 1) || - w <= 0 || h <= 0) - { - /* Not cropped; return the whole thing */ - return SDL_DisplayFormatAlpha(surf); - } + if ((top == 0 && bottom == surf->h - 1 && left == 0 && right == surf->w - 1) || w <= 0 || h <= 0) + { + /* Not cropped; return the whole thing */ + return SDL_DisplayFormatAlpha(surf); + } new_surf = SDL_CreateRGBSurface(surf->flags, w, h, surf->format->BitsPerPixel, - surf->format->Rmask, surf->format->Gmask, - surf->format->Bmask, surf->format->Amask); + surf->format->Rmask, surf->format->Gmask, surf->format->Bmask, surf->format->Amask); if (new_surf == NULL) - { - fprintf(stderr, "crop_surface() cannot create new surface!\n"); - return NULL; - } + { + fprintf(stderr, "crop_surface() cannot create new surface!\n"); + return NULL; + } src_rect.x = left; src_rect.y = top; @@ -10003,8 +9552,7 @@ static void create_button_labels(void) img_openlabels_play = do_render_button_label(gettext_noop("Play")); /* Slideshow: 'GIF Export' button, to create an animated GIF */ - img_openlabels_gif_export = - do_render_button_label(gettext_noop("GIF Export")); + img_openlabels_gif_export = do_render_button_label(gettext_noop("GIF Export")); /* Slideshow: 'Next' button, to load next slide (image) */ img_openlabels_next = do_render_button_label(gettext_noop("Next")); @@ -10069,8 +9617,7 @@ static void seticon(void) */ /* Load a mouse pointer (cursor) shape: */ static SDL_Cursor *get_cursor(unsigned char *bits, unsigned char *mask_bits, - unsigned int width, unsigned int height, - unsigned int x, unsigned int y) + unsigned int width, unsigned int height, unsigned int x, unsigned int y) { Uint8 b; Uint8 temp_bitmap[128], temp_bitmask[128]; @@ -10092,10 +9639,7 @@ static SDL_Cursor *get_cursor(unsigned char *bits, unsigned char *mask_bits, ((b & 0x02) << 5) | ((b & 0x04) << 3) | ((b & 0x08) << 1) | - ((b & 0x10) >> 1) | ((b & 0x20) >> 3) | ((b & 0x40) >> - 5) | ((b & - 0x80) >> - 7)); + ((b & 0x10) >> 1) | ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7)); b = mask_bits[i]; @@ -10103,10 +9647,7 @@ static SDL_Cursor *get_cursor(unsigned char *bits, unsigned char *mask_bits, ((b & 0x02) << 5) | ((b & 0x04) << 3) | ((b & 0x08) << 1) | - ((b & 0x10) >> 1) | ((b & 0x20) >> 3) | ((b & 0x40) >> - 5) | ((b & - 0x80) - >> 7)); + ((b & 0x10) >> 1) | ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7)); } return (SDL_CreateCursor(temp_bitmap, temp_bitmask, width, height, x, y)); @@ -10161,15 +9702,14 @@ static SDL_Surface *do_loadimage(const char *const fname, int abort_on_error) /* Load the image file: */ - s = myIMG_Load((char *) fname); + s = myIMG_Load((char *)fname); if (s == NULL) { if (abort_on_error) { fprintf(stderr, "\nError: I couldn't load a graphics file:\n" - "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", fname, SDL_GetError()); + "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", fname, SDL_GetError()); cleanup(); exit(1); @@ -10190,8 +9730,7 @@ static SDL_Surface *do_loadimage(const char *const fname, int abort_on_error) { fprintf(stderr, "\nError: I couldn't convert a graphics file:\n" - "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", fname, SDL_GetError()); + "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", fname, SDL_GetError()); SDL_FreeSurface(s); cleanup(); @@ -10251,9 +9790,7 @@ static void draw_toolbar(void) } dest.x = 0; - dest.y = - r_ttools.h + off_y + - ((most - gd_tools.cols + TOOLOFFSET) / gd_tools.cols * button_h); + dest.y = r_ttools.h + off_y + ((most - gd_tools.cols + TOOLOFFSET) / gd_tools.cols * button_h); @@ -10313,13 +9850,11 @@ static void draw_toolbar(void) dest.x = ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - ((40 * button_w) / ORIGINAL_BUTTON_SIZE - - img_tool_names[tool]->w) / 2; + ((40 * button_w) / ORIGINAL_BUTTON_SIZE - img_tool_names[tool]->w) / 2; dest.y = ((i / 2) * button_h) + r_ttools.h + (2 * button_w) / ORIGINAL_BUTTON_SIZE + - (((44 + button_label_y_nudge) * button_w) / ORIGINAL_BUTTON_SIZE - - img_tool_names[tool]->h) + off_y; + (((44 + button_label_y_nudge) * button_w) / ORIGINAL_BUTTON_SIZE - img_tool_names[tool]->h) + off_y; SDL_BlitSurface(img_tool_names[tool], NULL, screen, &dest); } @@ -10371,12 +9906,9 @@ static void draw_magic(void) } dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + img_scroll_down->h + - ((((most - 2) / 2) + TOOLOFFSET / 2) * button_h); + dest.y = r_ttoolopt.h + img_scroll_down->h + ((((most - 2) / 2) + TOOLOFFSET / 2) * button_h); - if (magic_scroll[magic_group] < - num_magics[magic_group] - (most - 2) - TOOLOFFSET) + if (magic_scroll[magic_group] < num_magics[magic_group] - (most - 2) - TOOLOFFSET) { SDL_BlitSurface(img_scroll_down, NULL, screen, &dest); } @@ -10392,8 +9924,7 @@ static void draw_magic(void) } - for (magic = magic_scroll[magic_group]; - magic < magic_scroll[magic_group] + max; magic++) + for (magic = magic_scroll[magic_group]; magic < magic_scroll[magic_group] + max; magic++) { i = magic - magic_scroll[magic_group]; @@ -10414,23 +9945,16 @@ static void draw_magic(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w + ((i % 2) * button_w) + 4; dest.y = ((i / 2) * button_h) + r_ttoolopt.h + 4 + off_y; - SDL_BlitSurface(magics[magic_group][magic].img_icon, NULL, screen, - &dest); + SDL_BlitSurface(magics[magic_group][magic].img_icon, NULL, screen, &dest); dest.x = WINDOW_WIDTH - r_ttoolopt.w + ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - ((40 * button_w) / ORIGINAL_BUTTON_SIZE - - magics[magic_group][magic].img_name->w) / 2; - dest.y = - (((i / 2) * button_h) + r_ttoolopt.h + - (4 * button_h) / ORIGINAL_BUTTON_SIZE + - ((44 * button_h) / ORIGINAL_BUTTON_SIZE - - magics[magic_group][magic].img_name->h) + off_y); // FIXME: CROP LABELS + ((40 * button_w) / ORIGINAL_BUTTON_SIZE - magics[magic_group][magic].img_name->w) / 2; + dest.y = (((i / 2) * button_h) + r_ttoolopt.h + (4 * button_h) / ORIGINAL_BUTTON_SIZE + ((44 * button_h) / ORIGINAL_BUTTON_SIZE - magics[magic_group][magic].img_name->h) + off_y); // FIXME: CROP LABELS - SDL_BlitSurface(magics[magic_group][magic].img_name, NULL, screen, - &dest); + SDL_BlitSurface(magics[magic_group][magic].img_name, NULL, screen, &dest); } else { @@ -10452,9 +9976,7 @@ static void draw_magic(void) SDL_BlitSurface(button_body, NULL, screen, &dest); dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_prev->w) / 2; - dest.y = - (r_ttoolopt.h + (((most + TOOLOFFSET) / 2) * button_h) + - (button_h - img_prev->h) / 2); + dest.y = (r_ttoolopt.h + (((most + TOOLOFFSET) / 2) * button_h) + (button_h - img_prev->h) / 2); SDL_BlitSurface(button_color, NULL, img_prev, NULL); SDL_BlitSurface(img_prev, NULL, screen, &dest); @@ -10465,15 +9987,12 @@ static void draw_magic(void) button_body = img_btn_nav; dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h); SDL_BlitSurface(button_body, NULL, screen, &dest); dest.x = WINDOW_WIDTH - button_w + (button_w - img_next->w) / 2; - dest.y = - (r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h) + - (button_h - img_next->h) / 2); + dest.y = (r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h) + (button_h - img_next->h) / 2); SDL_BlitSurface(button_color, NULL, img_next, NULL); SDL_BlitSurface(img_next, NULL, screen, &dest); @@ -10493,32 +10012,24 @@ static void draw_magic(void) /* Show paint button: */ if (magics[grp][cur].mode == MODE_PAINT - || magics[grp][cur].mode == MODE_ONECLICK - || magics[grp][cur].mode == MODE_PAINT_WITH_PREVIEW) + || magics[grp][cur].mode == MODE_ONECLICK || magics[grp][cur].mode == MODE_PAINT_WITH_PREVIEW) button_color = img_btn_down; /* Active */ else if (magics[grp][cur].avail_modes & MODE_PAINT - || magics[grp][cur].avail_modes & MODE_ONECLICK - || magics[grp][cur].avail_modes & MODE_PAINT_WITH_PREVIEW) + || magics[grp][cur].avail_modes & MODE_ONECLICK || magics[grp][cur].avail_modes & MODE_PAINT_WITH_PREVIEW) button_color = img_btn_up; /* Available, but not active */ else button_color = img_btn_off; /* Unavailable */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + - (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h); SDL_BlitSurface(button_color, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_magic_paint->w) / 2; + dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_magic_paint->w) / 2; dest.y = (r_ttoolopt.h + ((most / gd_toolopt.cols + - (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h) + (button_h - - img_magic_paint-> - h) / 2); + (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h) + (button_h - img_magic_paint->h) / 2); SDL_BlitSurface(img_magic_paint, NULL, screen, &dest); @@ -10533,21 +10044,15 @@ static void draw_magic(void) button_color = img_btn_off; /* Unavailable */ dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + - (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h); SDL_BlitSurface(button_color, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - button_w + (button_w - img_magic_fullscreen->w) / 2; + dest.x = WINDOW_WIDTH - button_w + (button_w - img_magic_fullscreen->w) / 2; dest.y = (r_ttoolopt.h + ((most / gd_toolopt.cols + - (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h) + (button_h - - img_magic_fullscreen-> - h) / 2); + (TOOLOFFSET + 2) / gd_toolopt.cols) * button_h) + (button_h - img_magic_fullscreen->h) / 2); SDL_BlitSurface(img_magic_fullscreen, NULL, screen, &dest); @@ -10564,19 +10069,20 @@ static void draw_magic(void) cur = cur_magic[magic_group]; mode = magic_modeint(magics[grp][cur].mode); - if (magics[grp][cur].sizes[mode] > 1) { + if (magics[grp][cur].sizes[mode] > 1) + { int i, xx, yy, sizes; float x_per, y_per; - SDL_Surface * blnk, * btn; + SDL_Surface *blnk, *btn; sizes = magics[grp][cur].sizes[mode]; - x_per = (float) r_ttoolopt.w / (float) sizes; - y_per = (float) button_h / (float) (sizes + 1); + x_per = (float)r_ttoolopt.w / (float)sizes; + y_per = (float)button_h / (float)(sizes + 1); for (i = 1; i < sizes + 1; i++) { xx = ceil(x_per); - yy = ceil(y_per * (float) i); + yy = ceil(y_per * (float)i); if (i <= magics[grp][cur].size[mode]) btn = thumbnail(img_btn_down, xx, yy, 0); @@ -10598,8 +10104,10 @@ static void draw_magic(void) SDL_FreeSurface(btn); SDL_FreeSurface(blnk); } - } else { - SDL_Surface * wide_button_off; + } + else + { + SDL_Surface *wide_button_off; /* Sizing not supported, just draw a big blank */ @@ -10652,24 +10160,18 @@ static unsigned draw_colors(unsigned action) old_color = cur_color; - for (i = 0; i < (unsigned int) NUM_COLORS; i++) + for (i = 0; i < (unsigned int)NUM_COLORS; i++) { dest.x = r_colors.x + i % gd_colors.cols * color_button_w; dest.y = r_colors.y + i / gd_colors.cols * color_button_h; #ifndef LOW_QUALITY_COLOR_SELECTOR SDL_BlitSurface((colors_state == COLORSEL_ENABLE) - ? img_color_btns[i + - (i == - cur_color) * - NUM_COLORS] : img_color_btn_off, NULL, - screen, &dest); + ? img_color_btns[i + (i == cur_color) * NUM_COLORS] : img_color_btn_off, NULL, screen, &dest); #else dest.w = color_button_w; dest.h = color_button_h; if (colors_state == COLORSEL_ENABLE) - SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, color_hexes[i][0], - color_hexes[i][1], color_hexes[i][2])); + SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, color_hexes[i][0], color_hexes[i][1], color_hexes[i][2])); else SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 240, 240, 240)); @@ -10689,17 +10191,14 @@ static unsigned draw_colors(unsigned action) /* If more than one colors rows, fill the parts of the r_tcolors not covered by the title. */ if (gd_colors.rows > 1) - SDL_FillRect(screen, &r_tcolors, - SDL_MapRGBA(screen->format, 255, 255, 255, 255)); + SDL_FillRect(screen, &r_tcolors, SDL_MapRGBA(screen->format, 255, 255, 255, 255)); if (colors_state == COLORSEL_ENABLE) { SDL_BlitSurface(img_title_large_on, NULL, screen, &r_tcolors); - dest.x = - r_tcolors.x + (r_tcolors.w - img_title_names[TITLE_COLORS]->w) / 2; - dest.y = - r_tcolors.y + (r_tcolors.h - img_title_names[TITLE_COLORS]->h) / 2; + dest.x = r_tcolors.x + (r_tcolors.w - img_title_names[TITLE_COLORS]->w) / 2; + dest.y = r_tcolors.y + (r_tcolors.h - img_title_names[TITLE_COLORS]->h) / 2; SDL_BlitSurface(img_title_names[TITLE_COLORS], NULL, screen, &dest); } else @@ -10755,9 +10254,7 @@ static void draw_brushes(void) } dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + img_scroll_up->h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + img_scroll_up->h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (brush_scroll < num_brushes - most - TOOLOFFSET) { @@ -10803,19 +10300,14 @@ static void draw_brushes(void) int ui_btn_x, ui_btn_y; if (brushes_directional[brush]) - src.x = - (img_brushes_thumbs[brush]->w / abs(brushes_frames[brush])) / 3; + src.x = (img_brushes_thumbs[brush]->w / abs(brushes_frames[brush])) / 3; else src.x = 0; - src.y = - brushes_directional[brush] ? (img_brushes_thumbs[brush]->h / 3) : 0; + src.y = brushes_directional[brush] ? (img_brushes_thumbs[brush]->h / 3) : 0; - src.w = - (img_brushes_thumbs[brush]->w / abs(brushes_frames[brush])) / - (brushes_directional[brush] ? 3 : 1); - src.h = - (img_brushes_thumbs[brush]->h / (brushes_directional[brush] ? 3 : 1)); + src.w = (img_brushes_thumbs[brush]->w / abs(brushes_frames[brush])) / (brushes_directional[brush] ? 3 : 1); + src.h = (img_brushes_thumbs[brush]->h / (brushes_directional[brush] ? 3 : 1)); ui_btn_x = ((i % 2) * button_w) + (WINDOW_WIDTH - r_ttoolopt.w); ui_btn_y = ((i / 2) * button_h) + r_ttoolopt.h + off_y; @@ -10858,12 +10350,10 @@ static void draw_brushes_spacing(void) /* Spacing ranges from 0px to "N x the max dimension of the brush" (so a 48x48 brush would have a spacing of 48 if the center option is chosen) */ - size_at = - ((BRUSH_SPACING_SIZES - 1) * brushes_spacing[cur_brush]) / (max(w, h) * - BRUSH_SPACING_MAX_MULTIPLIER); + size_at = ((BRUSH_SPACING_SIZES - 1) * brushes_spacing[cur_brush]) / (max(w, h) * BRUSH_SPACING_MAX_MULTIPLIER); - x_per = (float) r_ttoolopt.w / BRUSH_SPACING_SIZES; - y_per = (float) button_h / (BRUSH_SPACING_SIZES + 1); + x_per = (float)r_ttoolopt.w / BRUSH_SPACING_SIZES; + y_per = (float)button_h / (BRUSH_SPACING_SIZES + 1); for (i = 1; i < BRUSH_SPACING_SIZES + 1; i++) { @@ -10949,12 +10439,9 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w; dest.y = - r_ttoolopt.h + off_y + - (((most - gd_toolopt.cols) / gd_toolopt.cols + - TOOLOFFSET / gd_toolopt.cols) * button_h); + r_ttoolopt.h + off_y + (((most - gd_toolopt.cols) / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); - if (font_scroll < - num_font_families - (most - gd_toolopt.cols) - TOOLOFFSET) + if (font_scroll < num_font_families - (most - gd_toolopt.cols) - TOOLOFFSET) { SDL_BlitSurface(img_scroll_down, NULL, screen, &dest); } @@ -10999,7 +10486,7 @@ static void draw_fonts(void) if (font < num_font_families) { SDL_Surface *tmp_surf_1; - TuxPaint_Font * fonthandle; + TuxPaint_Font *fonthandle; /* Label for 'Letters' buttons (font selector, down the right when the Text or Label tool are being used); used to show the difference @@ -11009,11 +10496,14 @@ static void draw_fonts(void) back as identical rectangles, we know the font doesn't adequately support this font.) */ fonthandle = getfonthandle(font); - if (charset_works(fonthandle, gettext("Aa"))) { + if (charset_works(fonthandle, gettext("Aa"))) + { /* Use the localized label string (e.g., "あぁ" in Japanese) */ DEBUG_PRINTF("Font label '%s' for %s\n", gettext("Aa"), fonthandle->desc); tmp_surf_1 = render_text(fonthandle, gettext("Aa"), black); - } else { + } + else + { /* Fallback; use the latin "Aa" string */ DEBUG_PRINTF("Fallback font label 'Aa' for %s\n", fonthandle->desc); tmp_surf_1 = render_text(fonthandle, "Aa", black); @@ -11073,9 +10563,7 @@ static void draw_fonts(void) { /* "Apply Label" button */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (cur_label == LABEL_APPLY) SDL_BlitSurface(img_btn_down, NULL, screen, &dest); else @@ -11086,21 +10574,17 @@ static void draw_fonts(void) SDL_BlitSurface(img_btn_off, NULL, screen, &dest); } - dest.x = - WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_label_apply->w) / 2; + dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_label_apply->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_label_apply->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_label_apply->h) / 2); SDL_BlitSurface(img_label_apply, NULL, screen, &dest); /* "Select Label" button */ dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (cur_label == LABEL_SELECT) SDL_BlitSurface(img_btn_down, NULL, screen, &dest); @@ -11116,8 +10600,7 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - button_w + (button_w - img_label_select->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_label_select->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_label_select->h) / 2); SDL_BlitSurface(img_label_select, NULL, screen, &dest); @@ -11136,9 +10619,7 @@ static void draw_fonts(void) /* Show bold button: */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (text_state & TTF_STYLE_BOLD) SDL_BlitSurface(img_btn_down, NULL, screen, &dest); @@ -11148,8 +10629,7 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_bold->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_bold->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_bold->h) / 2); SDL_BlitSurface(img_bold, NULL, screen, &dest); @@ -11157,9 +10637,7 @@ static void draw_fonts(void) /* Show italic button: */ dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (text_state & TTF_STYLE_ITALIC) SDL_BlitSurface(img_btn_down, NULL, screen, &dest); @@ -11169,8 +10647,7 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - button_w + (button_w - img_italic->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_italic->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_italic->h) / 2); SDL_BlitSurface(img_italic, NULL, screen, &dest); @@ -11180,9 +10657,7 @@ static void draw_fonts(void) /* Show shrink button: */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (text_size > MIN_TEXT_SIZE) { @@ -11199,8 +10674,7 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_shrink->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_shrink->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_shrink->h) / 2); SDL_BlitSurface(button_color, NULL, img_shrink, NULL); SDL_BlitSurface(img_shrink, NULL, screen, &dest); @@ -11209,9 +10683,7 @@ static void draw_fonts(void) /* Show grow button: */ dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (text_size < MAX_TEXT_SIZE) { @@ -11228,8 +10700,7 @@ static void draw_fonts(void) dest.x = WINDOW_WIDTH - button_w + (button_w - img_grow->w) / 2; dest.y = (r_ttoolopt.h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + - (button_h - img_grow->h) / 2); + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h) + (button_h - img_grow->h) / 2); SDL_BlitSurface(button_color, NULL, img_grow, NULL); SDL_BlitSurface(img_grow, NULL, screen, &dest); @@ -11261,13 +10732,21 @@ static void draw_stamps(void) /* How many can we show? */ - if (!disable_stamp_controls) { - if (!no_stamp_rotation) { - most = (buttons_tall * gd_toolopt.cols) - gd_toolopt.cols - gd_toolopt.cols - gd_toolopt.cols - gd_toolopt.cols - TOOLOFFSET; - } else { + if (!disable_stamp_controls) + { + if (!no_stamp_rotation) + { + most = + (buttons_tall * gd_toolopt.cols) - gd_toolopt.cols - gd_toolopt.cols - gd_toolopt.cols - gd_toolopt.cols - + TOOLOFFSET; + } + else + { most = (buttons_tall * gd_toolopt.cols) - gd_toolopt.cols - gd_toolopt.cols - gd_toolopt.cols - TOOLOFFSET; } - } else { + } + else + { most = (buttons_tall * gd_toolopt.cols) - gd_toolopt.cols - TOOLOFFSET; } @@ -11297,12 +10776,12 @@ static void draw_stamps(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w; dest.y = r_ttoolopt.h + off_y + (((most + 2) / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); - if (!disable_stamp_controls) { + if (!disable_stamp_controls) + { dest.y -= (button_h * 2); } - if (stamp_scroll[stamp_group] < - num_stamps[stamp_group] - (most - 2) - TOOLOFFSET) + if (stamp_scroll[stamp_group] < num_stamps[stamp_group] - (most - 2) - TOOLOFFSET) { SDL_BlitSurface(img_scroll_down, NULL, screen, &dest); } @@ -11322,8 +10801,7 @@ static void draw_stamps(void) /* Draw each of the shown stamps: */ - for (stamp = stamp_scroll[stamp_group]; - stamp < stamp_scroll[stamp_group] + max; stamp++) + for (stamp = stamp_scroll[stamp_group]; stamp < stamp_scroll[stamp_group] + max; stamp++) { i = stamp - stamp_scroll[stamp_group]; @@ -11346,17 +10824,12 @@ static void draw_stamps(void) if (stamp < num_stamps[stamp_group]) { /* Loads the thumbnail and sounds, the sounds just if this is the current stamp, increasing responsivity for low powered devices */ - get_stamp_thumb(stamp_data[stamp_group][stamp], - stamp == cur_stamp[stamp_group] ? 1 : 0); + get_stamp_thumb(stamp_data[stamp_group][stamp], stamp == cur_stamp[stamp_group] ? 1 : 0); img = stamp_data[stamp_group][stamp]->thumbnail; - base_x = - ((i % 2) * button_w) + (WINDOW_WIDTH - r_ttoolopt.w) + - ((button_w - (img->w)) / 2); + base_x = ((i % 2) * button_w) + (WINDOW_WIDTH - r_ttoolopt.w) + ((button_w - (img->w)) / 2); - base_y = - ((i / 2) * button_h) + r_ttoolopt.h + ((button_h - (img->h)) / 2) + - off_y; + base_y = ((i / 2) * button_h) + r_ttoolopt.h + ((button_h - (img->h)) / 2) + off_y; dest.x = base_x; dest.y = base_y; @@ -11379,9 +10852,7 @@ static void draw_stamps(void) SDL_BlitSurface(button_body, NULL, screen, &dest); dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_prev->w) / 2; - dest.y = - (r_ttoolopt.h + (((most + TOOLOFFSET) / 2) * button_h) + - (button_h - img_prev->h) / 2); + dest.y = (r_ttoolopt.h + (((most + TOOLOFFSET) / 2) * button_h) + (button_h - img_prev->h) / 2); SDL_BlitSurface(button_color, NULL, img_prev, NULL); SDL_BlitSurface(img_prev, NULL, screen, &dest); @@ -11392,15 +10863,12 @@ static void draw_stamps(void) button_body = img_btn_nav; dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h); SDL_BlitSurface(button_body, NULL, screen, &dest); dest.x = WINDOW_WIDTH - button_w + (button_w - img_next->w) / 2; - dest.y = - (r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h) + - (button_h - img_next->h) / 2); + dest.y = (r_ttoolopt.h + (((most + TOOLOFFSET) / gd_toolopt.cols) * button_h) + (button_h - img_next->h) / 2); SDL_BlitSurface(button_color, NULL, img_next, NULL); SDL_BlitSurface(img_next, NULL, screen, &dest); @@ -11410,13 +10878,12 @@ static void draw_stamps(void) if (!disable_stamp_controls) { - if (!no_stamp_rotation) { + if (!no_stamp_rotation) + { /* Show rotation button */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); if (stamp_rotation_ctrl) button_body = img_btn_down; @@ -11428,8 +10895,7 @@ static void draw_stamps(void) dest.x = WINDOW_WIDTH - (button_w * 2) + (button_w - img_rotate->w) / 2; dest.y = (r_ttoolopt.h + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + - (button_h - img_rotate->h) / 2); + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + (button_h - img_rotate->h) / 2); SDL_BlitSurface(img_black, NULL, img_rotate, NULL); SDL_BlitSurface(img_rotate, NULL, screen, &dest); @@ -11437,26 +10903,24 @@ static void draw_stamps(void) /* No-op button */ dest.x = WINDOW_WIDTH - r_ttoolopt.w + button_w; - dest.y = - r_ttoolopt.h + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); SDL_BlitSurface(img_btn_off, NULL, screen, &dest); /* Push other buttons down */ off_y = button_h; - } else { + } + else + { off_y = 0; - } /* !no_stamp_rotation */ + } /* !no_stamp_rotation */ /* Show mirror button: */ dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + off_y + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + off_y + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); if (stamp_data[stamp_group][cur_stamp[stamp_group]]->mirrorable) { @@ -11481,8 +10945,7 @@ static void draw_stamps(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_mirror->w) / 2; dest.y = (r_ttoolopt.h + off_y + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + - (button_h - img_mirror->h) / 2); + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + (button_h - img_mirror->h) / 2); SDL_BlitSurface(button_color, NULL, img_mirror, NULL); SDL_BlitSurface(img_mirror, NULL, screen, &dest); @@ -11490,9 +10953,7 @@ static void draw_stamps(void) /* Show flip button: */ dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + off_y + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + off_y + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h); if (stamp_data[stamp_group][cur_stamp[stamp_group]]->flipable) { @@ -11517,20 +10978,17 @@ static void draw_stamps(void) dest.x = WINDOW_WIDTH - button_w + (button_w - img_flip->w) / 2; dest.y = (r_ttoolopt.h + off_y + - ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + - (button_h - img_flip->h) / 2); + ((most + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h) + (button_h - img_flip->h) / 2); SDL_BlitSurface(button_color, NULL, img_flip, NULL); SDL_BlitSurface(img_flip, NULL, screen, &dest); /* Stamp size control: */ sizes = MAX_STAMP_SIZE - MIN_STAMP_SIZE + 1; /* +1 for SF Bug #1668235 -bjk 2011.01.08 */ - size_at = - (stamp_data[stamp_group][cur_stamp[stamp_group]]->size - - MIN_STAMP_SIZE); + size_at = (stamp_data[stamp_group][cur_stamp[stamp_group]]->size - MIN_STAMP_SIZE); - x_per = (float) r_ttoolopt.w / sizes; - y_per = (float) button_h / sizes; + x_per = (float)r_ttoolopt.w / sizes; + y_per = (float)button_h / sizes; for (i = 0; i < sizes; i++) { @@ -11555,14 +11013,13 @@ static void draw_stamps(void) dest.x = (WINDOW_WIDTH - r_ttoolopt.w) + (i * x_per); dest.y = (((most + gd_toolopt.cols + gd_toolopt.cols + gd_toolopt.cols + - gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h)) - - 8 * button_scale - (y_per * i) + off_y; + gd_toolopt.cols + TOOLOFFSET) / gd_toolopt.cols * button_h)) - 8 * button_scale - (y_per * i) + off_y; SDL_BlitSurface(btn, NULL, screen, &dest); SDL_FreeSurface(btn); SDL_FreeSurface(blnk); } - } /* !disable_stamp_controls */ + } /* !disable_stamp_controls */ redraw_tux_text(); } @@ -11603,9 +11060,7 @@ static void draw_shapes(void) } dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + img_scroll_up->h + - ((((most - 2) / 2) + TOOLOFFSET / 2) * button_h); + dest.y = r_ttoolopt.h + img_scroll_up->h + ((((most - 2) / 2) + TOOLOFFSET / 2) * button_h); if (shape_scroll < NUM_SHAPES - (most - 2) - TOOLOFFSET) { @@ -11645,24 +11100,15 @@ static void draw_shapes(void) if (shape < NUM_SHAPES) { - dest.x = - ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - ((i / 2) * button_h) + r_ttoolopt.h + - (4 * button_h) / ORIGINAL_BUTTON_SIZE + off_y; + dest.x = ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + WINDOW_WIDTH - r_ttoolopt.w; + dest.y = ((i / 2) * button_h) + r_ttoolopt.h + (4 * button_h) / ORIGINAL_BUTTON_SIZE + off_y; SDL_BlitSurface(img_shapes[shape], NULL, screen, &dest); dest.x = ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - WINDOW_WIDTH - r_ttoolopt.w + - ((40 * button_w) / ORIGINAL_BUTTON_SIZE - - img_shape_names[shape]->w) / 2; - dest.y = - ((i / 2) * button_h) + r_ttoolopt.h + - (4 * button_h) / ORIGINAL_BUTTON_SIZE + - ((44 * button_h) / ORIGINAL_BUTTON_SIZE - img_shape_names[shape]->h) + // FIXME: CROP LABELS + WINDOW_WIDTH - r_ttoolopt.w + ((40 * button_w) / ORIGINAL_BUTTON_SIZE - img_shape_names[shape]->w) / 2; + dest.y = ((i / 2) * button_h) + r_ttoolopt.h + (4 * button_h) / ORIGINAL_BUTTON_SIZE + ((44 * button_h) / ORIGINAL_BUTTON_SIZE - img_shape_names[shape]->h) + // FIXME: CROP LABELS off_y; SDL_BlitSurface(img_shape_names[shape], NULL, screen, &dest); @@ -11683,16 +11129,13 @@ static void draw_shapes(void) button_color = img_btn_up; dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h); SDL_BlitSurface(button_color, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_shapes_center->w) / 2; + dest.x = WINDOW_WIDTH - r_ttoolopt.w + (button_w - img_shapes_center->w) / 2; dest.y = - (r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h) + - (button_h - img_shapes_center->h) / 2); + (r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h) + (button_h - img_shapes_center->h) / 2); SDL_BlitSurface(img_shapes_center, NULL, screen, &dest); @@ -11705,15 +11148,13 @@ static void draw_shapes(void) button_color = img_btn_up; dest.x = WINDOW_WIDTH - button_w; - dest.y = - r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h); + dest.y = r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h); SDL_BlitSurface(button_color, NULL, screen, &dest); dest.x = WINDOW_WIDTH - button_w + (button_w - img_shapes_corner->w) / 2; dest.y = - (r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h) + - (button_h - img_shapes_corner->h) / 2); + (r_ttoolopt.h + ((most + TOOLOFFSET) / gd_toolopt.cols * button_h) + (button_h - img_shapes_corner->h) / 2); SDL_BlitSurface(img_shapes_corner, NULL, screen, &dest); } @@ -11759,9 +11200,7 @@ static void draw_erasers(void) } dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + img_scroll_up->h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + img_scroll_up->h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (eraser_scroll < NUM_ERASERS - most - TOOLOFFSET) { @@ -11804,17 +11243,10 @@ static void draw_erasers(void) { /* Square */ - sz = - (2 + - (((NUM_ERASERS / 2) - 1 - - i) * (38 / ((NUM_ERASERS / 2) - 1)))) * button_scale; + sz = (2 + (((NUM_ERASERS / 2) - 1 - i) * (38 / ((NUM_ERASERS / 2) - 1)))) * button_scale; - x = - ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + - 24 * button_scale - sz / 2; - y = - ((j / 2) * button_h) + r_ttoolopt.h + 24 * button_scale - sz / 2 + - off_y; + x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2; + y = ((j / 2) * button_h) + r_ttoolopt.h + 24 * button_scale - sz / 2 + off_y; dest.x = x; dest.y = y; @@ -11848,18 +11280,10 @@ static void draw_erasers(void) { /* Circle */ - sz = - (2 + - (((NUM_ERASERS / 2) - 1 - - (i - NUM_ERASERS / 2)) * (38 / ((NUM_ERASERS / 2) - - 1)))) * button_scale; + sz = (2 + (((NUM_ERASERS / 2) - 1 - (i - NUM_ERASERS / 2)) * (38 / ((NUM_ERASERS / 2) - 1)))) * button_scale; - x = - ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + - 24 * button_scale - sz / 2; - y = - ((j / 2) * button_h) + 40 * button_scale + 24 * button_scale - - sz / 2 + off_y; + x = ((i % 2) * button_w) + WINDOW_WIDTH - r_ttoolopt.w + 24 * button_scale - sz / 2; + y = ((j / 2) * button_h) + 40 * button_scale + 24 * button_scale - sz / 2 + off_y; for (yy = 0; yy <= sz; yy++) { @@ -11869,17 +11293,13 @@ static void draw_erasers(void) if (n >= -sz && n <= sz) { - putpixel(screen, (x + sz / 2) + xx, (y + sz / 2) + yy, - SDL_MapRGB(screen->format, 0, 0, 0)); + putpixel(screen, (x + sz / 2) + xx, (y + sz / 2) + yy, SDL_MapRGB(screen->format, 0, 0, 0)); - putpixel(screen, (x + sz / 2) - xx, (y + sz / 2) + yy, - SDL_MapRGB(screen->format, 0, 0, 0)); + putpixel(screen, (x + sz / 2) - xx, (y + sz / 2) + yy, SDL_MapRGB(screen->format, 0, 0, 0)); - putpixel(screen, (x + sz / 2) + xx, (y + sz / 2) - yy, - SDL_MapRGB(screen->format, 0, 0, 0)); + putpixel(screen, (x + sz / 2) + xx, (y + sz / 2) - yy, SDL_MapRGB(screen->format, 0, 0, 0)); - putpixel(screen, (x + sz / 2) - xx, (y + sz / 2) - yy, - SDL_MapRGB(screen->format, 0, 0, 0)); + putpixel(screen, (x + sz / 2) - xx, (y + sz / 2) - yy, SDL_MapRGB(screen->format, 0, 0, 0)); } } @@ -11945,9 +11365,7 @@ static void draw_fills(void) } dest.x = WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - r_ttoolopt.h + img_scroll_up->h + - ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); + dest.y = r_ttoolopt.h + img_scroll_up->h + ((most / gd_toolopt.cols + TOOLOFFSET / gd_toolopt.cols) * button_h); if (fill_scroll < NUM_FILLS - most - TOOLOFFSET) { @@ -11986,23 +11404,15 @@ static void draw_fills(void) if (i < NUM_FILLS) { - dest.x = - ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - WINDOW_WIDTH - r_ttoolopt.w; - dest.y = - ((i / 2) * button_h) + r_ttoolopt.h + - (4 * button_h) / ORIGINAL_BUTTON_SIZE + off_y; + dest.x = ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + WINDOW_WIDTH - r_ttoolopt.w; + dest.y = ((i / 2) * button_h) + r_ttoolopt.h + (4 * button_h) / ORIGINAL_BUTTON_SIZE + off_y; SDL_BlitSurface(img_fills[i], NULL, screen, &dest); dest.x = ((i % 2) * button_w) + (4 * button_w) / ORIGINAL_BUTTON_SIZE + - WINDOW_WIDTH - r_ttoolopt.w + - ((40 * button_w) / ORIGINAL_BUTTON_SIZE - img_fill_names[i]->w) / 2; - dest.y = - ((i / 2) * button_h) + r_ttoolopt.h + - (4 * button_h) / ORIGINAL_BUTTON_SIZE + - ((44 * button_h) / ORIGINAL_BUTTON_SIZE - img_fill_names[i]->h) + // FIXME: CROP LABELS + WINDOW_WIDTH - r_ttoolopt.w + ((40 * button_w) / ORIGINAL_BUTTON_SIZE - img_fill_names[i]->w) / 2; + dest.y = ((i / 2) * button_h) + r_ttoolopt.h + (4 * button_h) / ORIGINAL_BUTTON_SIZE + ((44 * button_h) / ORIGINAL_BUTTON_SIZE - img_fill_names[i]->h) + // FIXME: CROP LABELS off_y; SDL_BlitSurface(img_fill_names[i], NULL, screen, &dest); @@ -12015,8 +11425,7 @@ static void draw_fills(void) * FIXME */ /* Create a thumbnail: */ -static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, - int keep_aspect) +static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, int keep_aspect) { return (thumbnail2(src, max_x, max_y, keep_aspect, 1)); } @@ -12024,12 +11433,12 @@ static SDL_Surface *thumbnail(SDL_Surface * src, int max_x, int max_y, /** * FIXME */ -static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, - int keep_aspect, int keep_alpha) +static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int keep_aspect, int keep_alpha) { int x, y; float src_x, src_y, off_x, off_y; SDL_Surface *s; + #ifdef GAMMA_CORRECTED_THUMBNAILS float tr, tg, tb, ta; #else @@ -12041,16 +11450,15 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, int tmp; void (*putpixel)(SDL_Surface *, int, int, Uint32); - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[src->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[src->format->BytesPerPixel]; /* Determine scale and centering offsets: */ if (!keep_aspect) { DEBUG_PRINTF("thumbnail2() asked for %d x %d => %d x %d, DON'T keep aspect\n", src->w, src->h, max_x, max_y); - yscale = (float) ((float) src->h / (float) max_y); - xscale = (float) ((float) src->w / (float) max_x); + yscale = (float)((float)src->h / (float)max_y); + xscale = (float)((float)src->w / (float)max_x); } else { @@ -12059,35 +11467,35 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, scale_factor = pick_best_scape(src->w, src->h, max_x, max_y); - sx = ((float) src->w * scale_factor); - sy = ((float) src->h * scale_factor); + sx = ((float)src->w * scale_factor); + sy = ((float)src->h * scale_factor); - yscale = (float) ((float) src->h / (float) sy); - xscale = (float) ((float) src->w / (float) sx); + yscale = (float)((float)src->h / (float)sy); + xscale = (float)((float)src->w / (float)sx); } - new_x = (int) ((float) src->w / xscale); - new_y = (int) ((float) src->h / yscale); + new_x = (int)((float)src->w / xscale); + new_y = (int)((float)src->h / yscale); if (!keep_aspect) - { - off_x = 0; - off_y = 0; - } + { + off_x = 0; + off_y = 0; + } else - { - off_x = ((float) max_x - (float) new_x) / 2.0; - off_y = ((float) max_y - (float) new_y) / 2.0; - DEBUG_PRINTF(" off_x = (%d - %d) / 2 = %.2f\n", max_x, new_x, off_x); - DEBUG_PRINTF(" off_y = (%d - %d) / 2 = %.2f\n", max_y, new_y, off_y); - } + { + off_x = ((float)max_x - (float)new_x) / 2.0; + off_y = ((float)max_y - (float)new_y) / 2.0; + DEBUG_PRINTF(" off_x = (%d - %d) / 2 = %.2f\n", max_x, new_x, off_x); + DEBUG_PRINTF(" off_y = (%d - %d) / 2 = %.2f\n", max_y, new_y, off_y); + } #ifndef NO_BILINEAR if (max_x > src->w && max_y > src->h) - { - DEBUG_PRINTF("Calling zoom(%d,%d)\n", new_x, new_y); - return (zoom(src, new_x, new_y)); - } + { + DEBUG_PRINTF("Calling zoom(%d,%d)\n", new_x, new_y); + return (zoom(src, new_x, new_y)); + } #endif @@ -12095,15 +11503,13 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, s = SDL_CreateRGBSurface(src->flags, /* SDL_SWSURFACE, */ max_x, max_y, src->format->BitsPerPixel, - src->format->Rmask, src->format->Gmask, - src->format->Bmask, src->format->Amask); + src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); if (s == NULL) { fprintf(stderr, "\nError: Can't build stamp thumbnails\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -12128,14 +11534,11 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, tmp = 0; - for (src_y = y * yscale; src_y < y * yscale + yscale && src_y < src->h; - src_y++) + for (src_y = y * yscale; src_y < y * yscale + yscale && src_y < src->h; src_y++) { - for (src_x = x * xscale; - src_x < x * xscale + xscale && src_x < src->w; src_x++) + for (src_x = x * xscale; src_x < x * xscale + xscale && src_x < src->w; src_x++) { - SDL_GetRGBA(getpixel(src, src_x, src_y), src->format, &r, &g, &b, - &a); + SDL_GetRGBA(getpixel(src, src_x, src_y), src->format, &r, &g, &b, &a); #ifdef GAMMA_CORRECTED_THUMBNAILS /* per: http://www.4p8.com/eric.brasseur/gamma.html */ @@ -12173,17 +11576,11 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, tg = ((ta * tg) / 255) + (255 - ta); tb = ((ta * tb) / 255) + (255 - ta); - putpixel(s, x + off_x, y + off_y, - SDL_MapRGBA(s->format, (Uint8) tr, (Uint8) tg, (Uint8) tb, - 0xff)); + putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format, (Uint8) tr, (Uint8) tg, (Uint8) tb, 0xff)); } else { - putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format, - (Uint8) tr, - (Uint8) tg, - (Uint8) tb, - (Uint8) ta)); + putpixel(s, x + off_x, y + off_y, SDL_MapRGBA(s->format, (Uint8) tr, (Uint8) tg, (Uint8) tb, (Uint8) ta)); } } #else @@ -12214,12 +11611,10 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h) SDL_Surface *s; void (*putpixel)(SDL_Surface *, int, int, Uint32); - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[src->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[src->format->BytesPerPixel]; float xscale, yscale; int x, y; - float floor_x, ceil_x, floor_y, ceil_y, fraction_x, fraction_y, one_minus_x, - one_minus_y; + float floor_x, ceil_x, floor_y, ceil_y, fraction_x, fraction_y, one_minus_x, one_minus_y; float n1, n2; float r1, g1, b1, a1; float r2, g2, b2, a2; @@ -12232,15 +11627,13 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h) s = SDL_CreateRGBSurface(src->flags, /* SDL_SWSURFACE, */ new_w, new_h, src->format->BitsPerPixel, - src->format->Rmask, src->format->Gmask, - src->format->Bmask, src->format->Amask); + src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); if (s == NULL) { fprintf(stderr, "\nError: Can't build zoom surface\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -12252,19 +11645,19 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h) SDL_LockSurface(src); SDL_LockSurface(s); - xscale = (float) src->w / (float) new_w; - yscale = (float) src->h / (float) new_h; + xscale = (float)src->w / (float)new_w; + yscale = (float)src->h / (float)new_h; for (x = 0; x < new_w; x++) { for (y = 0; y < new_h; y++) { - floor_x = floor((float) x * xscale); + floor_x = floor((float)x * xscale); ceil_x = floor_x + 1; if (ceil_x >= src->w) ceil_x = floor_x; - floor_y = floor((float) y * yscale); + floor_y = floor((float)y * yscale); ceil_y = floor_y + 1; if (ceil_y >= src->h) ceil_y = floor_y; @@ -12279,30 +11672,26 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h) { //EP added local block to avoid warning "Passing arg 3 from incompatible pointer type" of section below block Uint8 r, g, b, a; - SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, &r, &g, &b, - &a); - r1 = (float) r; - g1 = (float) g; - b1 = (float) b; - a1 = (float) a; - SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, &r, &g, &b, - &a); - r2 = (float) r; - g2 = (float) g; - b2 = (float) b; - a2 = (float) a; - SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format, &r, &g, &b, - &a); - r3 = (float) r; - g3 = (float) g; - b3 = (float) b; - a3 = (float) a; - SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, &r, &g, &b, - &a); - r4 = (float) r; - g4 = (float) g; - b4 = (float) b; - a4 = (float) a; + SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, &r, &g, &b, &a); + r1 = (float)r; + g1 = (float)g; + b1 = (float)b; + a1 = (float)a; + SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, &r, &g, &b, &a); + r2 = (float)r; + g2 = (float)g; + b2 = (float)b; + a2 = (float)a; + SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format, &r, &g, &b, &a); + r3 = (float)r; + g3 = (float)g; + b3 = (float)b; + a3 = (float)a; + SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, &r, &g, &b, &a); + r4 = (float)r; + g4 = (float)g; + b4 = (float)b; + a4 = (float)a; } /* SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, @@ -12320,33 +11709,29 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h) r = g = b = a = 0; /* Unused, bah! */ - SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, &r, &g, &b, - &a); - r1 = (float) r; - g1 = (float) g; - b1 = (float) b; - a1 = (float) a; + SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, &r, &g, &b, &a); + r1 = (float)r; + g1 = (float)g; + b1 = (float)b; + a1 = (float)a; - SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, &r, &g, &b, - &a); - r2 = (float) r; - g2 = (float) g; - b2 = (float) b; - a2 = (float) a; + SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, &r, &g, &b, &a); + r2 = (float)r; + g2 = (float)g; + b2 = (float)b; + a2 = (float)a; - SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format, &r, &g, &b, - &a); - r3 = (float) r; - g3 = (float) g; - b3 = (float) b; - a3 = (float) a; + SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format, &r, &g, &b, &a); + r3 = (float)r; + g3 = (float)g; + b3 = (float)b; + a3 = (float)a; - SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, &r, &g, &b, - &a); - r4 = (float) r; - g4 = (float) g; - b4 = (float) b; - a4 = (float) a; + SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, &r, &g, &b, &a); + r4 = (float)r; + g4 = (float)g; + b4 = (float)b; + a4 = (float)a; } #endif @@ -12419,8 +11804,7 @@ static void _xorpixel(SDL_Surface * surf, int x, int y) static void xorpixel(int x, int y) { /* if outside the canvas, return */ - if ((unsigned) x >= (unsigned) canvas->w - || (unsigned) y >= (unsigned) canvas->h) + if ((unsigned)x >= (unsigned)canvas->w || (unsigned)y >= (unsigned)canvas->h) return; /* now switch to screen coordinates */ @@ -12468,8 +11852,7 @@ static void do_undo(void) } } - update_canvas(0, 0, (WINDOW_WIDTH - r_ttoolopt.w), - (button_h * 7) + 40 + HEIGHTOFFSET); + update_canvas(0, 0, (WINDOW_WIDTH - r_ttoolopt.w), (button_h * 7) + 40 + HEIGHTOFFSET); if (cur_undo == oldest_undo) @@ -12526,8 +11909,7 @@ static void do_redo(void) do_redo_label_node(); SDL_BlitSurface(undo_bufs[cur_undo], NULL, canvas, NULL); - update_canvas(0, 0, (WINDOW_WIDTH - r_ttoolopt.w), - (button_h * 7) + 40 + HEIGHTOFFSET); + update_canvas(0, 0, (WINDOW_WIDTH - r_ttoolopt.w), (button_h * 7) + 40 + HEIGHTOFFSET); been_saved = 0; } @@ -12557,10 +11939,8 @@ static void render_brush(void) int x, y; Uint8 r, g, b, a; - Uint32(*getpixel_brush) (SDL_Surface *, int, int) = - getpixels[img_brushes[cur_brush]->format->BytesPerPixel]; - void (*putpixel_brush)(SDL_Surface *, int, int, Uint32) = - putpixels[img_brushes[cur_brush]->format->BytesPerPixel]; + Uint32(*getpixel_brush) (SDL_Surface *, int, int) = getpixels[img_brushes[cur_brush]->format->BytesPerPixel]; + void (*putpixel_brush)(SDL_Surface *, int, int, Uint32) = putpixels[img_brushes[cur_brush]->format->BytesPerPixel]; /* Kludge; not sure why cur_brush would become greater! */ @@ -12580,8 +11960,7 @@ static void render_brush(void) /* Create a surface to render into: */ amask = ~(img_brushes[cur_brush]->format->Rmask | - img_brushes[cur_brush]->format->Gmask | img_brushes[cur_brush]-> - format->Bmask); + img_brushes[cur_brush]->format->Gmask | img_brushes[cur_brush]->format->Bmask); img_cur_brush = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -12589,14 +11968,12 @@ static void render_brush(void) img_brushes[cur_brush]->h, img_brushes[cur_brush]->format->BitsPerPixel, img_brushes[cur_brush]->format->Rmask, - img_brushes[cur_brush]->format->Gmask, - img_brushes[cur_brush]->format->Bmask, amask); + img_brushes[cur_brush]->format->Gmask, img_brushes[cur_brush]->format->Bmask, amask); if (img_cur_brush == NULL) { fprintf(stderr, "\nError: Can't render a brush!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -12612,24 +11989,20 @@ static void render_brush(void) { for (x = 0; x < img_brushes[cur_brush]->w; x++) { - SDL_GetRGBA(getpixel_brush(img_brushes[cur_brush], x, y), - img_brushes[cur_brush]->format, &r, &g, &b, &a); + SDL_GetRGBA(getpixel_brush(img_brushes[cur_brush], x, y), img_brushes[cur_brush]->format, &r, &g, &b, &a); if (r == g && g == b) { putpixel_brush(img_cur_brush, x, y, SDL_MapRGBA(img_cur_brush->format, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2], a)); + color_hexes[cur_color][0], color_hexes[cur_color][1], color_hexes[cur_color][2], a)); } else { putpixel_brush(img_cur_brush, x, y, SDL_MapRGBA(img_cur_brush->format, (r + color_hexes[cur_color][0]) >> 1, - (g + color_hexes[cur_color][1]) >> 1, - (b + color_hexes[cur_color][2]) >> 1, a)); + (g + color_hexes[cur_color][1]) >> 1, (b + color_hexes[cur_color][2]) >> 1, a)); } } } @@ -12638,10 +12011,8 @@ static void render_brush(void) SDL_UnlockSurface(img_brushes[cur_brush]); img_cur_brush_frame_w = img_cur_brush->w / abs(brushes_frames[cur_brush]); - img_cur_brush_w = - img_cur_brush_frame_w / (brushes_directional[cur_brush] ? 3 : 1); - img_cur_brush_h = - img_cur_brush->h / (brushes_directional[cur_brush] ? 3 : 1); + img_cur_brush_w = img_cur_brush_frame_w / (brushes_directional[cur_brush] ? 3 : 1); + img_cur_brush_h = img_cur_brush->h / (brushes_directional[cur_brush] ? 3 : 1); img_cur_brush_frames = brushes_frames[cur_brush]; img_cur_brush_directional = brushes_directional[cur_brush]; img_cur_brush_rotate = brushes_rotate[cur_brush]; @@ -12699,7 +12070,7 @@ static void line_xor(int x1, int y1, int x2, int y2) if (dx != 0) { - m = ((float) dy) / ((float) dx); + m = ((float)dy) / ((float)dx); b = y1 - m * x1; if (x2 >= x1) @@ -12832,9 +12203,7 @@ static int calc_eraser_size(int which_eraser) if (which_eraser >= NUM_SIZES) which_eraser -= NUM_SIZES; - return (((NUM_SIZES - 1 - - which_eraser) * ((ERASER_MAX - ERASER_MIN) / (NUM_SIZES - 1))) + - ERASER_MIN); + return (((NUM_SIZES - 1 - which_eraser) * ((ERASER_MAX - ERASER_MIN) / (NUM_SIZES - 1))) + ERASER_MIN); } /** @@ -12859,9 +12228,7 @@ static void do_eraser(int x, int y, int update) dest.h = sz; if (img_starter_bkgd == NULL) - SDL_FillRect(canvas, &dest, - SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, - canvas_color_b)); + SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, canvas_color_b)); else SDL_BlitSurface(img_starter_bkgd, &dest, canvas, &dest); } @@ -12887,10 +12254,7 @@ static void do_eraser(int x, int y, int update) dest.h = 1; if (img_starter_bkgd == NULL) - SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, - canvas_color_r, - canvas_color_g, - canvas_color_b)); + SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, canvas_color_b)); else SDL_BlitSurface(img_starter_bkgd, &dest, canvas, &dest); @@ -12901,10 +12265,7 @@ static void do_eraser(int x, int y, int update) dest.h = 1; if (img_starter_bkgd == NULL) - SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, - canvas_color_r, - canvas_color_g, - canvas_color_b)); + SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, canvas_color_b)); else SDL_BlitSurface(img_starter_bkgd, &dest, canvas, &dest); } @@ -12973,7 +12334,7 @@ static void eraser_draw(int x1, int y1, int x2, int y2) if (dx != 0) { - m = ((float) dy) / ((float) dx); + m = ((float)dy) / ((float)dx); b = y1 - m * x1; if (x2 >= x1) @@ -13030,8 +12391,7 @@ static void eraser_draw(int x1, int y1, int x2, int y2) } length = (calc_eraser_size(cur_eraser) >> 1) + 1; - update_canvas(orig_x1 - length, orig_y1 - length, orig_x2 + length, - orig_y2 + length); + update_canvas(orig_x1 - length, orig_y1 - length, orig_x2 + length, orig_y2 + length); } /** @@ -13174,8 +12534,7 @@ static int compare_dirent2s_invert(struct dirent2 *f1, struct dirent2 *f2) * FIXME */ /* Draw tux's text on the screen: */ -static void draw_tux_text(int which_tux, const char *const str, - int want_right_to_left) +static void draw_tux_text(int which_tux, const char *const str, int want_right_to_left) { draw_tux_text_ex(which_tux, str, want_right_to_left, 0); } @@ -13190,15 +12549,13 @@ static Uint8 latest_locale_text; */ static void redraw_tux_text(void) { - draw_tux_text_ex(latest_tux, latest_tux_text, latest_r2l, - latest_locale_text); + draw_tux_text_ex(latest_tux, latest_tux_text, latest_r2l, latest_locale_text); } /** * FIXME */ -static void draw_tux_text_ex(int which_tux, const char *const str, - int want_right_to_left, Uint8 locale_text) +static void draw_tux_text_ex(int which_tux, const char *const str, int want_right_to_left, Uint8 locale_text) { SDL_Rect dest; SDL_Color black = { 0, 0, 0, 0 }; @@ -13237,8 +12594,7 @@ static void draw_tux_text_ex(int which_tux, const char *const str, /* Wide enough for Tux, or two stamp sound buttons (whichever's wider) */ w = max(img_tux[which_tux]->w, img_btnsm_up->w * 2) + 5; - wordwrap_text_ex(str, black, w, r_tuxarea.y, r_tuxarea.w, - want_right_to_left, locale_text); + wordwrap_text_ex(str, black, w, r_tuxarea.y, r_tuxarea.w, want_right_to_left, locale_text); /* Draw 'sound effect' and 'speak' buttons, if we're in the Stamp tool */ @@ -13302,8 +12658,7 @@ static void draw_cur_tool_tip(void) else if (cur_tool == TOOL_SHAPES) { draw_tux_text(tool_tux[cur_tool], - shape_tool_tips[simple_shapes ? SHAPE_COMPLEXITY_SIMPLE : - SHAPE_COMPLEXITY_NORMAL], 1); + shape_tool_tips[simple_shapes ? SHAPE_COMPLEXITY_SIMPLE : SHAPE_COMPLEXITY_NORMAL], 1); } else { @@ -13314,8 +12669,7 @@ static void draw_cur_tool_tip(void) /** * FIXME */ -static void wordwrap_text(const char *const str, SDL_Color color, int left, - int top, int right, int want_right_to_left) +static void wordwrap_text(const char *const str, SDL_Color color, int left, int top, int right, int want_right_to_left) { wordwrap_text_ex(str, color, left, top, right, want_right_to_left, 0); } @@ -13324,8 +12678,7 @@ static void wordwrap_text(const char *const str, SDL_Color color, int left, * FIXME */ static void wordwrap_text_ex(const char *const str, SDL_Color color, - int left, int top, int right, - int want_right_to_left, Uint8 locale_text) + int left, int top, int right, int want_right_to_left, Uint8 locale_text) { SDL_Surface *text; TuxPaint_Font *myfont = medium_font; @@ -13366,39 +12719,32 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, sdl_color_to_pango_color(color, &pango_color); SDLPango_SetDefaultColor(myfont->pango_context, &pango_color); - SDLPango_SetMinimumSize(myfont->pango_context, right - left, - canvas->h - top); + SDLPango_SetMinimumSize(myfont->pango_context, right - left, canvas->h - top); if (want_right_to_left && need_right_to_left) { - SDLPango_SetBaseDirection(locale_font->pango_context, - SDLPANGO_DIRECTION_RTL); + SDLPango_SetBaseDirection(locale_font->pango_context, SDLPANGO_DIRECTION_RTL); if (only_uppercase) { char *upper_str = uppercase(gettext(str)); - SDLPango_SetText_GivenAlignment(myfont->pango_context, upper_str, -1, - SDLPANGO_ALIGN_RIGHT); + SDLPango_SetText_GivenAlignment(myfont->pango_context, upper_str, -1, SDLPANGO_ALIGN_RIGHT); free(upper_str); } else - SDLPango_SetText_GivenAlignment(myfont->pango_context, gettext(str), -1, - SDLPANGO_ALIGN_RIGHT); + SDLPango_SetText_GivenAlignment(myfont->pango_context, gettext(str), -1, SDLPANGO_ALIGN_RIGHT); } else { - SDLPango_SetBaseDirection(locale_font->pango_context, - SDLPANGO_DIRECTION_LTR); + SDLPango_SetBaseDirection(locale_font->pango_context, SDLPANGO_DIRECTION_LTR); if (only_uppercase) { char *upper_str = uppercase(gettext(str)); - SDLPango_SetText_GivenAlignment(myfont->pango_context, upper_str, -1, - SDLPANGO_ALIGN_LEFT); + SDLPango_SetText_GivenAlignment(myfont->pango_context, upper_str, -1, SDLPANGO_ALIGN_LEFT); free(upper_str); } else - SDLPango_SetText_GivenAlignment(myfont->pango_context, gettext(str), -1, - SDLPANGO_ALIGN_LEFT); + SDLPango_SetText_GivenAlignment(myfont->pango_context, gettext(str), -1, SDLPANGO_ALIGN_LEFT); } text = SDLPango_CreateSurfaceDraw(myfont->pango_context); @@ -13426,9 +12772,9 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (strcmp(str, "") != 0) { if (want_right_to_left == 0) - locale_str = (unsigned char *) strdup(gettext(str)); + locale_str = (unsigned char *)strdup(gettext(str)); else - locale_str = (unsigned char *) textdir(gettext(str)); + locale_str = (unsigned char *)textdir(gettext(str)); /* For each UTF8 character: */ @@ -13436,7 +12782,7 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, utf8_str_len = 0; utf8_str[0] = '\0'; - for (i = 0; i <= strlen((char *) locale_str); i++) + for (i = 0; i <= strlen((char *)locale_str); i++) { if (locale_str[i] < 128) { @@ -13450,13 +12796,13 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, { if (only_uppercase) { - char *upper_utf8_str = uppercase((char *) utf8_str); + char *upper_utf8_str = uppercase((char *)utf8_str); - text = render_text(myfont, (char *) upper_utf8_str, color); + text = render_text(myfont, (char *)upper_utf8_str, color); free(upper_utf8_str); } else - text = render_text(myfont, (char *) utf8_str, color); + text = render_text(myfont, (char *)utf8_str, color); if (!text) continue; /* Didn't render anything... */ @@ -13469,8 +12815,7 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (x > left) { if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, - y + text->h, x - left); + anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); x = left; y = y + text->h; @@ -13522,14 +12867,13 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (utf8_char[0] != '\0') { - text = render_text(myfont, (char *) utf8_char, color); + text = render_text(myfont, (char *)utf8_char, color); if (text != NULL) { if (x + text->w > right) { if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, - y + text->h, x - left); + anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); x = left; y = y + text->h; @@ -13562,8 +12906,7 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, /* This word needs to move down? */ if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, - y + text->h, x - left); + anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); x = left; y = y + text->h; @@ -13675,8 +13018,7 @@ static void wordwrap_text_ex(const char *const str, SDL_Color color, if (x + text->w > right) /* Correct? */ { if (need_right_to_left && want_right_to_left) - anti_carriage_return(left, right, top, top + text->h, y + text->h, - x - left); + anti_carriage_return(left, right, top, top + text->h, y + text->h, x - left); x = left; y = y + text->h; @@ -13755,7 +13097,7 @@ static void playstampdesc(int chan) playsound_event.type = SDL_USEREVENT; playsound_event.user.code = USEREVENT_PLAYDESCSOUND; - playsound_event.user.data1 = (void *) (intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64 + playsound_event.user.data1 = (void *)(intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64 SDL_PushEvent(&playsound_event); } @@ -13795,7 +13137,7 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.ogg", extra, lang_prefix); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13805,7 +13147,7 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.wav", extra, lang_prefix); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13816,9 +13158,8 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) /* Check for non-country-code locale */ strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ - safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.ogg", extra, - short_lang_prefix); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.ogg", extra, short_lang_prefix); + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13827,9 +13168,8 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) debug("...No short local version of sound (OGG)!"); strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ - safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.wav", extra, - short_lang_prefix); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + safe_snprintf(tmp_str, sizeof(tmp_str), "%s_%s.wav", extra, short_lang_prefix); + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13839,13 +13179,14 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) debug("...No short local version of sound (WAV)!"); - if (strcmp(extra, "_desc") != 0 || strcmp(short_lang_prefix, "en") == 0) { + if (strcmp(extra, "_desc") != 0 || strcmp(short_lang_prefix, "en") == 0) + { /* (Not loading a descriptive sound, or we're in English locale, go ahead and fall back; i.e., if loading a descriptive sound in a non-English locale, let's not load the English version; see https://sourceforge.net/p/tuxpaint/bugs/261/) */ - strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ + strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ safe_snprintf(tmp_str, sizeof(tmp_str), "%s.ogg", extra); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13853,9 +13194,9 @@ static Mix_Chunk *loadsound_extra(const char *const fname, const char *extra) { debug("...No default version of sound (OGG)!"); - strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ + strcpy(snd_fname, fname); /* malloc'd size should be sufficient */ safe_snprintf(tmp_str, sizeof(tmp_str), "%s.wav", extra); - strcpy((char *) strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ + strcpy((char *)strcasestr(snd_fname, ext), tmp_str); /* FIXME: Use strncpy() (ugh, complicated) */ debug(snd_fname); tmp_snd = Mix_LoadWAV(snd_fname); @@ -13941,7 +13282,7 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text) /* Set the first available language */ for (i = 0; i < num_wished_langs && !found; i++) { - strcpy((char *) extptr, ".txt"); /* safe; pointing into a safe spot within an existing string (txt_fname) */ + strcpy((char *)extptr, ".txt"); /* safe; pointing into a safe spot within an existing string (txt_fname) */ fi = fopen(txt_fname, "r"); if (!fi) return NULL; @@ -13971,14 +13312,12 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text) // lang_prefix = lang_prefixes[langint]; /* See if it's the one for this locale... */ - if ((char *) strcasestr(buf, wished_langs[i].lang_prefix) == buf) + if ((char *)strcasestr(buf, wished_langs[i].lang_prefix) == buf) { debug(buf + strlen(wished_langs[i].lang_prefix)); - if ((char *) - strcasestr(buf + strlen(wished_langs[i].lang_prefix), - ".utf8=") == - buf + strlen(wished_langs[i].lang_prefix)) + if ((char *)strcasestr(buf + strlen(wished_langs[i].lang_prefix), + ".utf8=") == buf + strlen(wished_langs[i].lang_prefix)) { lang_prefix = wished_langs[i].lang_prefix; short_lang_prefix = strdup(lang_prefix); @@ -13988,8 +13327,7 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text) need_own_font = wished_langs[i].need_own_font; need_right_to_left = wished_langs[i].need_right_to_left; - need_right_to_left_word = - wished_langs[i].need_right_to_left_word; + need_right_to_left_word = wished_langs[i].need_right_to_left_word; found = 1; @@ -14023,8 +13361,7 @@ static char *loaddesc(const char *const fname, Uint8 * locale_text) } else { - fprintf(stderr, "Somehow, '%s' doesn't have a filename extension!?\n", - fname); + fprintf(stderr, "Somehow, '%s' doesn't have a filename extension!?\n", fname); return NULL; } } @@ -14062,8 +13399,7 @@ static double loadinfo(const char *const fname, stamp_type * inf) inf->colorable = 1; else if (strcmp(buf, "tintable") == 0) inf->tintable = 1; - else if (!memcmp(buf, "scale", 5) - && (isspace(buf[5]) || buf[5] == '=')) + else if (!memcmp(buf, "scale", 5) && (isspace(buf[5]) || buf[5] == '=')) { double tmp, tmp2; char *cp = buf + 6; @@ -14083,8 +13419,7 @@ static double loadinfo(const char *const fname, stamp_type * inf) cp++; tmp2 = strtod(cp, NULL); if (tmp > 0.0001 && tmp < 10000.0 && tmp2 > 0.0001 - && tmp2 < 10000.0 && tmp / tmp2 > 0.0001 - && tmp / tmp2 < 10000.0) + && tmp2 < 10000.0 && tmp / tmp2 > 0.0001 && tmp / tmp2 < 10000.0) ratio = tmp / tmp2; } else if (strchr(cp, ':')) @@ -14094,8 +13429,7 @@ static double loadinfo(const char *const fname, stamp_type * inf) cp++; tmp2 = strtod(cp, NULL); if (tmp > 0.0001 && tmp < 10000.0 && - tmp2 > 0.0001 && tmp2 < 10000.0 && tmp2 / tmp > 0.0001 - && tmp2 / tmp < 10000.0) + tmp2 > 0.0001 && tmp2 < 10000.0 && tmp2 / tmp > 0.0001 && tmp2 / tmp < 10000.0) ratio = tmp2 / tmp; } else @@ -14105,8 +13439,7 @@ static double loadinfo(const char *const fname, stamp_type * inf) ratio = 1.0 / tmp; } } - else if (!memcmp(buf, "tinter", 6) - && (isspace(buf[6]) || buf[6] == '=')) + else if (!memcmp(buf, "tinter", 6) && (isspace(buf[6]) || buf[6] == '=')) { char *cp = buf + 7; @@ -14150,8 +13483,7 @@ static double loadinfo(const char *const fname, stamp_type * inf) /** * FIXME */ -static int SDLCALL NondefectiveBlit(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) +static int SDLCALL NondefectiveBlit(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { int dstx = 0; int dsty = 0; @@ -14160,10 +13492,8 @@ static int SDLCALL NondefectiveBlit(SDL_Surface * src, const SDL_Rect * srcrect, int srcw = src->w; int srch = src->h; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[src->format->BytesPerPixel]; - void (*putpixel)(SDL_Surface *, int, int, Uint32) = - putpixels[dst->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[src->format->BytesPerPixel]; + void (*putpixel)(SDL_Surface *, int, int, Uint32) = putpixels[dst->format->BytesPerPixel]; if (srcrect) @@ -14207,8 +13537,7 @@ static int SDLCALL NondefectiveBlit(SDL_Surface * src, const SDL_Rect * srcrect, while (i--) { - putpixel(dst, i + dstx, srch + dsty, - getpixel(src, i + srcx, srch + srcy)); + putpixel(dst, i + dstx, srch + dsty, getpixel(src, i + srcx, srch + srcy)); } } @@ -14227,8 +13556,7 @@ static int SDLCALL NondefectiveBlit(SDL_Surface * src, const SDL_Rect * srcrect, static void autoscale_copy_smear_free(SDL_Surface * src, SDL_Surface * dst, int SDLCALL(*blit) (SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, - SDL_Rect * dstrect)) + SDL_Surface * dst, SDL_Rect * dstrect)) { SDL_Surface *src1; SDL_Rect dest; @@ -14239,7 +13567,7 @@ static void autoscale_copy_smear_free(SDL_Surface * src, SDL_Surface * dst, in the gaps via a smear. */ if (src->w != dst->w || src->h != dst->h) { - if (src->w / (float) dst->w > src->h / (float) dst->h) + if (src->w / (float)dst->w > src->h / (float)dst->h) src1 = thumbnail(src, dst->w, src->h * dst->w / src->w, 0); else src1 = thumbnail(src, src->w * dst->h / src->h, dst->h, 0); @@ -14316,59 +13644,69 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * int SDLCALL(*blit) (SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, - SDL_Rect * dstrect), - starter_template_options_t opts) { + SDL_Rect * dstrect), starter_template_options_t opts) +{ int new_w, new_h; float src_aspect, dst_aspect; new_w = src->w; new_h = src->h; - src_aspect = (float) src->w / (float) src->h; - dst_aspect = (float) dst->w / (float) dst->h; + src_aspect = (float)src->w / (float)src->h; + dst_aspect = (float)dst->w / (float)dst->h; - if (src_aspect > dst_aspect) { - DEBUG_PRINTF("Image (%d x %d) is of a wider aspect (%0.5f) than canvas (%d x %d) (%0.5f)\n", src->w, src->h, src_aspect, dst->w, dst->h, dst_aspect); - if (opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_HORIZ || - opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_BOTH) { + if (src_aspect > dst_aspect) + { + DEBUG_PRINTF("Image (%d x %d) is of a wider aspect (%0.5f) than canvas (%d x %d) (%0.5f)\n", src->w, src->h, + src_aspect, dst->w, dst->h, dst_aspect); + if (opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_HORIZ || opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_BOTH) + { new_h = dst->h; new_w = dst->h * src_aspect; DEBUG_PRINTF("Okay to crop left/right. Keeping aspect; scaling to %d x %d\n", new_w, new_h); } - } else if (src_aspect < dst_aspect) { - DEBUG_PRINTF("Image (%d x %d) is of a taller aspect (%0.5f) than canvas (%d x %d) (%0.5f)\n", src->w, src->h, src_aspect, dst->w, dst->h, dst_aspect); - if (opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_VERT || - opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_BOTH) { + } + else if (src_aspect < dst_aspect) + { + DEBUG_PRINTF("Image (%d x %d) is of a taller aspect (%0.5f) than canvas (%d x %d) (%0.5f)\n", src->w, src->h, + src_aspect, dst->w, dst->h, dst_aspect); + if (opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_VERT || opts.scale_mode == STARTER_TEMPLATE_SCALE_MODE_BOTH) + { new_w = dst->w; new_h = dst->w / src_aspect; DEBUG_PRINTF("Okay to crop top/bottom. Keeping aspect; scaling to %d x %d\n", new_w, new_h); } - } else { - DEBUG_PRINTF("Image (%d x %d) is the same aspect as canvas (%d x %d) (%0.05f)\n", src->w, src->h, dst->w, dst->h, src_aspect); + } + else + { + DEBUG_PRINTF("Image (%d x %d) is the same aspect as canvas (%d x %d) (%0.05f)\n", src->w, src->h, dst->w, dst->h, + src_aspect); } /* Scale and crop based on any aspect-ratio-keeping adjustments */ - if (new_w != src->w || new_h != src->h) { - SDL_Surface * scaled, * src1; + if (new_w != src->w || new_h != src->h) + { + SDL_Surface *scaled, *src1; SDL_Rect src_rect; /* Scale, keeping aspect, which will cause extra content that needs cropping */ DEBUG_PRINTF("Scaling from %d x %d to %d x %d\n", src->w, src->h, new_w, new_h); - scaled = thumbnail2(src, new_w, new_h, 0 /* keep aspect */, 1 /* keep alpha */); - if (scaled == NULL) { + scaled = thumbnail2(src, new_w, new_h, 0 /* keep aspect */ , 1 /* keep alpha */ ); + if (scaled == NULL) + { fprintf(stderr, "Failed to scale an image!\n"); return; } /* Create a new surface to blit (crop) into */ - src1 = SDL_CreateRGBSurface(src->flags, /* SDL_SWSURFACE, */ + src1 = SDL_CreateRGBSurface(src->flags, /* SDL_SWSURFACE, */ dst->w, dst->h, src->format->BitsPerPixel, - src->format->Rmask, src->format->Gmask, - src->format->Bmask, src->format->Amask); - if (src1 == NULL) { + src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); + if (src1 == NULL) + { fprintf(stderr, "Failed to create a surface!\n"); return; } @@ -14377,19 +13715,29 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * src = src1; /* Place the new image onto the dest */ - if (opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT) { + if (opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT) + { src_rect.x = 0; - } else if (opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT) { + } + else if (opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT) + { src_rect.x = scaled->w - dst->w; - } else /* opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER */ { + } + else /* opts.h_gravity == STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER */ + { src_rect.x = (scaled->w - dst->w) / 2; } - if (opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_TOP) { + if (opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_TOP) + { src_rect.y = 0; - } else if (opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM) { + } + else if (opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM) + { src_rect.y = scaled->h - dst->h; - } else /* opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_CENTER */ { + } + else /* opts.v_gravity == STARTER_TEMPLATE_GRAVITY_VERT_CENTER */ + { src_rect.y = (scaled->h - dst->h) / 2; } @@ -14403,21 +13751,29 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * } - if (src->w != dst->w || src->h != dst->h) { + if (src->w != dst->w || src->h != dst->h) + { DEBUG_PRINTF("Fitting %d x %d onto %d x %d canvas\n", src->w, src->h, dst->w, dst->h); - if (opts.smear) { + if (opts.smear) + { autoscale_copy_smear_free(src, dst, blit); /* Note: autoscale_copy_smear_free() calls SDL_FreeSurface(src)! */ - } else { - SDL_Surface * scaled; + } + else + { + SDL_Surface *scaled; SDL_Rect dst_rect; - if (src->w != dst->w || src->h != dst->h) { - if (src->w / (float) dst->w > src->h / (float) dst->h) { + if (src->w != dst->w || src->h != dst->h) + { + if (src->w / (float)dst->w > src->h / (float)dst->h) + { DEBUG_PRINTF("Scaling from %d x %d to %d x %d\n", src->w, src->h, dst->w, src->h * dst->w / src->w); scaled = thumbnail(src, dst->w, src->h * dst->w / src->w, 0); - } else { + } + else + { DEBUG_PRINTF("Scaling from %d x %d to %d x %d\n", src->w, src->h, src->w * dst->h / src->h, dst->h); scaled = thumbnail(src, src->w * dst->h / src->h, dst->h, 0); } @@ -14425,7 +13781,8 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * SDL_FreeSurface(src); - if (scaled == NULL) { + if (scaled == NULL) + { fprintf(stderr, "Failed to scale an image!\n"); return; } @@ -14443,7 +13800,9 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * SDL_FreeSurface(scaled); } - } else { + } + else + { DEBUG_PRINTF("No smearing or background needed\n"); autoscale_copy_smear_free(src, dst, blit); @@ -14460,10 +13819,11 @@ static void autoscale_copy_scale_or_smear_free(SDL_Surface * src, SDL_Surface * * @param char * img_id -- basename of image * @param starter_template_options_t * opts -- pointer to options struct to fill */ -static void get_starter_template_options(char * dirname, char * img_id, starter_template_options_t * opts) { +static void get_starter_template_options(char *dirname, char *img_id, starter_template_options_t * opts) +{ char fname[256], buf[256]; - char * arg; - FILE * fi; + char *arg; + FILE *fi; /* Set defaults for all options (in case file missing, or file doesn't specify certain options) */ opts->scale_mode = STARTER_TEMPLATE_SCALE_MODE_NONE; @@ -14477,76 +13837,118 @@ static void get_starter_template_options(char * dirname, char * img_id, starter_ /* Attempt to open the file */ safe_snprintf(fname, sizeof(fname), "%s/%s.dat", dirname, img_id); fi = fopen(fname, "r"); - if (fi == NULL) { + if (fi == NULL) + { return; } - while (!feof(fi)) { + while (!feof(fi)) + { if (fgets(buf, sizeof(buf), fi)) { if (!feof(fi)) { strip_trailing_whitespace(buf); - if (buf[0] == '\0' || buf[0] == '#') { + if (buf[0] == '\0' || buf[0] == '#') + { continue; } arg = strchr(buf, '='); - if (arg) { + if (arg) + { *arg++ = '\0'; - } else { + } + else + { fprintf(stderr, "Don't understand line in '%s': '%s'\n", fname, buf); continue; } - if (strcmp(buf, "allowscale") == 0) { - if (strcmp(arg, "horizontal") == 0) { + if (strcmp(buf, "allowscale") == 0) + { + if (strcmp(arg, "horizontal") == 0) + { opts->scale_mode = STARTER_TEMPLATE_SCALE_MODE_HORIZ; - } else if (strcmp(arg, "vertical") == 0) { + } + else if (strcmp(arg, "vertical") == 0) + { opts->scale_mode = STARTER_TEMPLATE_SCALE_MODE_VERT; - } else if (strcmp(arg, "both") == 0) { + } + else if (strcmp(arg, "both") == 0) + { opts->scale_mode = STARTER_TEMPLATE_SCALE_MODE_BOTH; - } else if (strcmp(arg, "none") == 0) { + } + else if (strcmp(arg, "none") == 0) + { opts->scale_mode = STARTER_TEMPLATE_SCALE_MODE_NONE; - } else { + } + else + { fprintf(stderr, "Unknown 'autoscale' option in '%s': '%s'\n", fname, arg); } - } else if (strcmp(buf, "gravity") == 0) { - if (strcmp(arg, "top") == 0) { + } + else if (strcmp(buf, "gravity") == 0) + { + if (strcmp(arg, "top") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_TOP; - } else if (strcmp(arg, "bottom") == 0) { + } + else if (strcmp(arg, "bottom") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM; - } else if (strcmp(arg, "left") == 0) { + } + else if (strcmp(arg, "left") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_CENTER; - } else if (strcmp(arg, "right") == 0) { + } + else if (strcmp(arg, "right") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_CENTER; - } else if (strcmp(arg, "top-left") == 0) { + } + else if (strcmp(arg, "top-left") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_TOP; - } else if (strcmp(arg, "bottom-left") == 0) { + } + else if (strcmp(arg, "bottom-left") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_LEFT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM; - } else if (strcmp(arg, "top-right") == 0) { + } + else if (strcmp(arg, "top-right") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_TOP; - } else if (strcmp(arg, "bottom-right") == 0) { + } + else if (strcmp(arg, "bottom-right") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_RIGHT; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_BOTTOM; - } else if (strcmp(arg, "center") == 0) { + } + else if (strcmp(arg, "center") == 0) + { opts->h_gravity = STARTER_TEMPLATE_GRAVITY_HORIZ_CENTER; opts->v_gravity = STARTER_TEMPLATE_GRAVITY_VERT_CENTER; - } else { + } + else + { fprintf(stderr, "Unknown 'autoscale' option in '%s': '%s'\n", fname, arg); } - } else if (strcmp(buf, "background") == 0) { - if (strcmp(arg, "smear") == 0) { + } + else if (strcmp(buf, "background") == 0) + { + if (strcmp(arg, "smear") == 0) + { opts->smear = 1; - } else { + } + else + { int count; char tmp_str[256]; @@ -14566,12 +13968,9 @@ static void get_starter_template_options(char * dirname, char * img_id, starter_ /* Byte (#rrggbb) form */ - opts->bkgd_color[0] = - (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[1]); - opts->bkgd_color[1] = - (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[3]); - opts->bkgd_color[2] = - (hex2dec(tmp_str[4]) << 4) + hex2dec(tmp_str[5]); + opts->bkgd_color[0] = (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[1]); + opts->bkgd_color[1] = (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[3]); + opts->bkgd_color[2] = (hex2dec(tmp_str[4]) << 4) + hex2dec(tmp_str[5]); } else if (strlen(tmp_str) == 3) { @@ -14579,13 +13978,12 @@ static void get_starter_template_options(char * dirname, char * img_id, starter_ /* Nybble (#rgb) form */ - opts->bkgd_color[0] = - (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[0]); - opts->bkgd_color[1] = - (hex2dec(tmp_str[1]) << 4) + hex2dec(tmp_str[1]); - opts->bkgd_color[2] = - (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[2]); - } else { + opts->bkgd_color[0] = (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[0]); + opts->bkgd_color[1] = (hex2dec(tmp_str[1]) << 4) + hex2dec(tmp_str[1]); + opts->bkgd_color[2] = (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[2]); + } + else + { fprintf(stderr, "Don't understand color hex '%s'\n", arg); } } @@ -14596,15 +13994,16 @@ static void get_starter_template_options(char * dirname, char * img_id, starter_ /* Assume int form */ sscanf(arg, "%hu %hu %hu %n", - (short unsigned int *) &(opts->bkgd_color[0]), - (short unsigned int *) &(opts->bkgd_color[1]), - (short unsigned int *) &(opts->bkgd_color[2]), - &count); + (short unsigned int *)&(opts->bkgd_color[0]), + (short unsigned int *)&(opts->bkgd_color[1]), + (short unsigned int *)&(opts->bkgd_color[2]), &count); } DEBUG_PRINTF("Background color: %d,%d,%d\n", opts->bkgd_color[0], opts->bkgd_color[1], opts->bkgd_color[2]); } - } else { + } + else + { fprintf(stderr, "Unrecognized option in '%s': '%s' (set to '%s')\n", fname, buf, arg); continue; } @@ -14718,9 +14117,7 @@ static void load_starter_id(char *saved_id, FILE * fil) * FIXME */ static SDL_Surface *load_starter_helper(char *path_and_basename, - const char *extension, - SDL_Surface * - (*load_func) (const char *)) + const char *extension, SDL_Surface * (*load_func) (const char *)) { char *ext; char fname[256]; @@ -14852,10 +14249,8 @@ static void load_starter(char *img_id) { int x, y; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[img_starter->format->BytesPerPixel]; - void (*putpixel)(SDL_Surface *, int, int, Uint32) = - putpixels[img_starter->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[img_starter->format->BytesPerPixel]; + void (*putpixel)(SDL_Surface *, int, int, Uint32) = putpixels[img_starter->format->BytesPerPixel]; Uint32 p; Uint8 r, g, b, a; int any_transparency; @@ -14901,8 +14296,7 @@ static void load_starter(char *img_id) /* Scale if needed... */ - if (img_starter != NULL - && (img_starter->w != canvas->w || img_starter->h != canvas->h)) + if (img_starter != NULL && (img_starter->w != canvas->w || img_starter->h != canvas->h)) { tmp_surf = img_starter; @@ -14910,9 +14304,7 @@ static void load_starter(char *img_id) canvas->w, canvas->h, tmp_surf->format->BitsPerPixel, tmp_surf->format->Rmask, - tmp_surf->format->Gmask, - tmp_surf->format->Bmask, - tmp_surf->format->Amask); + tmp_surf->format->Gmask, tmp_surf->format->Bmask, tmp_surf->format->Amask); /* 3rd arg ignored for RGBA surfaces */ // SDL_SetAlpha(tmp_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); @@ -14928,18 +14320,14 @@ static void load_starter(char *img_id) } - if (img_starter_bkgd != NULL - && (img_starter_bkgd->w != canvas->w - || img_starter_bkgd->h != canvas->h)) + if (img_starter_bkgd != NULL && (img_starter_bkgd->w != canvas->w || img_starter_bkgd->h != canvas->h)) { tmp_surf = img_starter_bkgd; img_starter_bkgd = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); autoscale_copy_scale_or_smear_free(tmp_surf, img_starter_bkgd, SDL_BlitSurface, template_options); } @@ -15014,18 +14402,14 @@ static void load_template(char *img_id) /* Scale if needed... */ - if (img_starter_bkgd != NULL - && (img_starter_bkgd->w != canvas->w - || img_starter_bkgd->h != canvas->h)) + if (img_starter_bkgd != NULL && (img_starter_bkgd->w != canvas->w || img_starter_bkgd->h != canvas->h)) { tmp_surf = img_starter_bkgd; img_starter_bkgd = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); autoscale_copy_scale_or_smear_free(tmp_surf, img_starter_bkgd, SDL_BlitSurface, template_options); } @@ -15045,8 +14429,7 @@ static void determine_id(void) { fprintf(stderr, "\nWarning: Couldn't determine the current image's ID\n" - "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, - strerror(errno)); + "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, strerror(errno)); file_id[0] = '\0'; starter_id[0] = '\0'; template_id[0] = '\0'; @@ -15076,6 +14459,7 @@ static void load_current(void) SDL_Surface *tmp, *org_surf; char *fname; char ftmp[1024]; + #ifdef AUTOSAVE_GOING_BACKGROUND FILE *fi; #endif @@ -15123,8 +14507,7 @@ static void load_current(void) { fprintf(stderr, "\nWarning: Couldn't load any current image.\n" - "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", fname, SDL_GetError()); + "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", fname, SDL_GetError()); file_id[0] = '\0'; starter_id[0] = '\0'; @@ -15174,8 +14557,7 @@ static void load_current(void) { /* Set file_id to the draw that were edited when the autosave triggered */ determine_id(); - snprintf(ftmp, sizeof(ftmp), "saved/%s%s", AUTOSAVED_NAME, - FNAME_EXTENSION); + snprintf(ftmp, sizeof(ftmp), "saved/%s%s", AUTOSAVED_NAME, FNAME_EXTENSION); fname = get_fname(ftmp, DIR_SAVE); unlink(fname); free(fname); @@ -15200,9 +14582,7 @@ static int make_directory(int dir_type, const char *path, const char *errmsg) res = mkdir(fname, 0755); if (res != 0 && errno != EEXIST) { - fprintf(stderr, - "\nError: %s:\n" "%s\n" "The error that occurred was:\n" "%s\n\n", - errmsg, fname, strerror(errno)); + fprintf(stderr, "\nError: %s:\n" "%s\n" "The error that occurred was:\n" "%s\n\n", errmsg, fname, strerror(errno)); free(fname); return 0; } @@ -15219,8 +14599,7 @@ static void save_current(void) char *fname; FILE *fi; - if (!make_directory - (DIR_SAVE, "", "Can't create user data directory (E001)")) + if (!make_directory(DIR_SAVE, "", "Can't create user data directory (E001)")) { draw_tux_text(TUX_OOPS, strerror(errno), 0); return; @@ -15233,8 +14612,7 @@ static void save_current(void) { fprintf(stderr, "\nError: Can't keep track of current image.\n" - "%s\n" "The error that occurred was:\n" "%s\n\n", fname, - strerror(errno)); + "%s\n" "The error that occurred was:\n" "%s\n\n", fname, strerror(errno)); draw_tux_text(TUX_OOPS, strerror(errno), 0); } @@ -15252,8 +14630,7 @@ static void save_current(void) * FIXME */ /* Prompt the user with a yes/no question: */ -static int do_prompt(const char *const text, const char *const btn_yes, - const char *const btn_no, int ox, int oy) +static int do_prompt(const char *const text, const char *const btn_yes, const char *const btn_no, int ox, int oy) { return (do_prompt_image(text, btn_yes, btn_no, NULL, NULL, NULL, ox, oy)); } @@ -15264,8 +14641,7 @@ static int do_prompt(const char *const text, const char *const btn_yes, static int do_prompt_snd(const char *const text, const char *const btn_yes, const char *const btn_no, int snd, int ox, int oy) { - return (do_prompt_image_flash_snd - (text, btn_yes, btn_no, NULL, NULL, NULL, 0, snd, ox, oy)); + return (do_prompt_image_flash_snd(text, btn_yes, btn_no, NULL, NULL, NULL, 0, snd, ox, oy)); } /** @@ -15273,11 +14649,9 @@ static int do_prompt_snd(const char *const text, const char *const btn_yes, */ static int do_prompt_image(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, int ox, - int oy) + SDL_Surface * img2, SDL_Surface * img3, int ox, int oy) { - return (do_prompt_image_snd - (text, btn_yes, btn_no, img1, img2, img3, SND_NONE, ox, oy)); + return (do_prompt_image_snd(text, btn_yes, btn_no, img1, img2, img3, SND_NONE, ox, oy)); } /** @@ -15286,11 +14660,9 @@ static int do_prompt_image(const char *const text, const char *const btn_yes, static int do_prompt_image_snd(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, - int snd, int ox, int oy) + SDL_Surface * img2, SDL_Surface * img3, int snd, int ox, int oy) { - return (do_prompt_image_flash_snd - (text, btn_yes, btn_no, img1, img2, img3, 0, snd, ox, oy)); + return (do_prompt_image_flash_snd(text, btn_yes, btn_no, img1, img2, img3, 0, snd, ox, oy)); } /** @@ -15299,12 +14671,9 @@ static int do_prompt_image_snd(const char *const text, static int do_prompt_image_flash(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, - SDL_Surface * img2, SDL_Surface * img3, - int animate, int ox, int oy) + SDL_Surface * img2, SDL_Surface * img3, int animate, int ox, int oy) { - return (do_prompt_image_flash_snd - (text, btn_yes, btn_no, img1, img2, img3, animate, SND_NONE, ox, - oy)); + return (do_prompt_image_flash_snd(text, btn_yes, btn_no, img1, img2, img3, animate, SND_NONE, ox, oy)); } #define PROMPT_W (min(canvas->w, ((int) (440 * button_scale)))) @@ -15317,8 +14686,7 @@ static int do_prompt_image_flash_snd(const char *const text, const char *const btn_yes, const char *const btn_no, SDL_Surface * img1, SDL_Surface * img2, - SDL_Surface * img3, int animate, int snd, - int ox, int oy) + SDL_Surface * img3, int animate, int snd, int ox, int oy) { int oox, ooy, nx, ny; SDL_Event event; @@ -15381,25 +14749,24 @@ static int do_prompt_image_flash_snd(const char *const text, backup = SDL_CreateRGBSurface(screen->flags, screen->w, screen->h, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_FillRect(backup, NULL, SDL_MapRGBA(backup->format, 255, 255, 255, 255)); SDL_BlitSurface(screen, NULL, backup, NULL); /* - * This loop creates an animation effect of the dialog box popping up. To - * ensure the animation plays at the same speed regardless of the platform and - * resource available at the time, capture the rate at which each frame is - * being drawn and draw the next frame at the adaptive rate. - */ + * This loop creates an animation effect of the dialog box popping up. To + * ensure the animation plays at the same speed regardless of the platform and + * resource available at the time, capture the rate at which each frame is + * being drawn and draw the next frame at the adaptive rate. + */ { Uint32 anim_ms = 120; Uint32 last_ms = SDL_GetTicks(); w = 0; - while(w <= r_ttools.w) + while (w <= r_ttools.w) { Uint32 next_ms = 0; Uint32 dw = 0; @@ -15415,35 +14782,39 @@ static int do_prompt_image_flash_snd(const char *const text, dest.w = (PROMPT_W - r_ttools.w * 2) + w * 2; dest.h = w * 2; SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 224 - (int) (w / button_scale), - 224 - (int) (w / button_scale), - 244 - (int) (w / button_scale))); + SDL_MapRGB(screen->format, 224 - (int)(w / button_scale), + 224 - (int)(w / button_scale), 244 - (int)(w / button_scale))); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); /* Calculate the amount by which to move to the next animation frame */ - if(w < r_ttools.w-2) { - while(1) { + if (w < r_ttools.w - 2) + { + while (1) + { next_ms = SDL_GetTicks(); - dw = ((next_ms - last_ms) * r_ttools.w + r_tools.w/2) / anim_ms; - if(dw) break; + dw = ((next_ms - last_ms) * r_ttools.w + r_tools.w / 2) / anim_ms; + if (dw) + break; /* This platform is so fast that there is no new frame to draw. * Yield some time then recalculate the next frame. */ SDL_Delay(1); } w += dw; - w = min(w, r_ttools.w-2); + w = min(w, r_ttools.w - 2); last_ms = next_ms; } - else if(w == r_ttools.w-2) { + else if (w == r_ttools.w - 2) + { /* Draw the dialog box. The dialog box is drawn 1 frame before the last * frame because the last frame draws the top and left borders. We * also skip a frame for artistic reasons. */ SDL_BlitSurface(backup, NULL, screen, NULL); w += 2; } - else { + else + { w += 2; } } @@ -15460,21 +14831,16 @@ static int do_prompt_image_flash_snd(const char *const text, (w - 4) * 2, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); if (alpha_surf != NULL) { - SDL_FillRect(alpha_surf, NULL, - SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); + SDL_FillRect(alpha_surf, NULL, SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); for (i = 8; i > 0; i = i - 2) { dest.x = PROMPT_LEFT + r_ttools.w - (w - 4) + i + PROMPTOFFSETX; - dest.y = - 94 / button_scale + r_ttools.w / button_scale - (w - 4) + i + - PROMPTOFFSETY; + dest.y = 94 / button_scale + r_ttools.w / button_scale - (w - 4) + i + PROMPTOFFSETY; dest.w = (PROMPT_W - r_ttools.w * 2) + (w - 4) * 2; dest.h = (w - 4) * 2; dest.y = canvas->h / 2 - dest.h / 2 + i + 2; @@ -15503,8 +14869,7 @@ static int do_prompt_image_flash_snd(const char *const text, if (img1 != NULL) { - if (img1->h > 64 * button_scale - && img2 != NULL /* Only scale if it matters */ ) + if (img1->h > 64 * button_scale && img2 != NULL /* Only scale if it matters */ ) { img1b = thumbnail(img1, 80 * button_scale, 64 * button_scale, 1); free_img1b = 1; @@ -15688,25 +15053,20 @@ static int do_prompt_image_flash_snd(const char *const text, } } } - else if (event.type == SDL_MOUSEBUTTONDOWN - && valid_click(event.button.button)) + else if (event.type == SDL_MOUSEBUTTONDOWN && valid_click(event.button.button)) { - if (event.button.x >= btn_left - && event.button.x < btn_left + img_yes->w) + if (event.button.x >= btn_left && event.button.x < btn_left + img_yes->w) { if (event.button.y >= dest_back.y + dest_back.h - 4 - button_h - 4 - button_h - && event.button.y < - dest_back.y + dest_back.h - 4 - button_h - 4 - button_h + - img_yes->h) + && event.button.y < dest_back.y + dest_back.h - 4 - button_h - 4 - button_h + img_yes->h) { ans = 1; done = 1; } else if (strlen(btn_no) != 0 && event.button.y >= dest_back.y + dest_back.h - 4 - button_h - && event.button.y < - dest_back.y + dest_back.h - 4 - button_h + img_no->h) + && event.button.y < dest_back.y + dest_back.h - 4 - button_h + img_no->h) { ans = 0; done = 1; @@ -15724,9 +15084,7 @@ static int do_prompt_image_flash_snd(const char *const text, img_yes->h) || (strlen(btn_no) != 0 && event.button.y >= dest_back.y + dest_back.h - 4 - button_h - && event.button.y < - dest_back.y + dest_back.h - 4 - button_h + - img_no->h))) + && event.button.y < dest_back.y + dest_back.h - 4 - button_h + img_no->h))) { do_setcursor(cursor_hand); } @@ -15742,8 +15100,7 @@ static int do_prompt_image_flash_snd(const char *const text, handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) @@ -15754,8 +15111,7 @@ static int do_prompt_image_flash_snd(const char *const text, } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); @@ -16014,21 +15370,21 @@ static void cleanup(void) if (medium_font != NULL) { - DEBUG_PRINTF("cleanup: medium font\n"); //EP + DEBUG_PRINTF("cleanup: medium font\n"); //EP TuxPaint_Font_CloseFont(medium_font); medium_font = NULL; } if (small_font != NULL) { - DEBUG_PRINTF("cleanup: small font\n"); //EP + DEBUG_PRINTF("cleanup: small font\n"); //EP TuxPaint_Font_CloseFont(small_font); small_font = NULL; } if (large_font != NULL) { - DEBUG_PRINTF("cleanup: large font\n"); //EP + DEBUG_PRINTF("cleanup: large font\n"); //EP TuxPaint_Font_CloseFont(large_font); large_font = NULL; } @@ -16136,8 +15492,7 @@ static void cleanup(void) { fprintf(stderr, "\nWarning: I couldn't create the lockfile (%s)\n" - "The error that occurred was:\n" "%s\n\n", lock_fname, - strerror(errno)); + "The error that occurred was:\n" "%s\n\n", lock_fname, strerror(errno)); } free(lock_fname); @@ -16213,7 +15568,8 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) float a1, a2, rotn_rad, init_ang, angle_skip; int xx, yy, offx, offy, max_x, max_y; - if (ny < sy) { + if (ny < sy) + { rotn = (rotn + 180) % 360; } @@ -16266,7 +15622,7 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) /* Draw the shape: */ - angle_skip = 360.0 / (float) shape_sides[cur_shape]; + angle_skip = 360.0 / (float)shape_sides[cur_shape]; init_ang = shape_init_ang[cur_shape]; @@ -16287,8 +15643,8 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) { a1 = (angle_skip * side + init_ang) * M_PI / 180.0; a2 = (angle_skip * (side + 1) + init_ang) * M_PI / 180.0; - x1 = (cos(a1) * (float) rx); - y1 = (-sin(a1) * (float) ry); + x1 = (cos(a1) * (float)rx); + y1 = (-sin(a1) * (float)ry); if (fabsf(x1) > max_x) max_x = fabsf(x1); @@ -16297,9 +15653,9 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) } if (max_x < rx) - rx = (rx * rx) / (int) max_x; + rx = (rx * rx) / (int)max_x; if (max_y < ry) - ry = (ry * ry) / (int) max_y; + ry = (ry * ry) / (int)max_y; } @@ -16347,20 +15703,20 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) for (side = 0; side < shape_sides[cur_shape]; side = side + step) { - a1 = (angle_skip * (float) side + init_ang) * M_PI / 180.0; + a1 = (angle_skip * (float)side + init_ang) * M_PI / 180.0; - x1 = (cos(a1) * (float) rx); - y1 = (-sin(a1) * (float) ry); + x1 = (cos(a1) * (float)rx); + y1 = (-sin(a1) * (float)ry); - a2 = (angle_skip * ((float) side + 1.0) + init_ang) * M_PI / 180.0; + a2 = (angle_skip * ((float)side + 1.0) + init_ang) * M_PI / 180.0; - x2 = (cos(a2) * (float) rx); - y2 = (-sin(a2) * (float) ry); + x2 = (cos(a2) * (float)rx); + y2 = (-sin(a2) * (float)ry); -printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2, y2); + printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2, y2); - xv = (cos((a1 + a2) / 2.0) * (float) rx * (float) shape_valley[cur_shape]) / 100.0; - yv = (-sin((a1 + a2) / 2.0) * (float) ry * (float) shape_valley[cur_shape]) / 100.0; + xv = (cos((a1 + a2) / 2.0) * (float)rx * (float)shape_valley[cur_shape]) / 100.0; + yv = (-sin((a1 + a2) / 2.0) * (float)ry * (float)shape_valley[cur_shape]) / 100.0; /* Rotate the line: */ @@ -16368,7 +15724,8 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 { rotn_rad = rotn * M_PI / 180.0; - if (shape_mode == SHAPEMODE_CENTER) { + if (shape_mode == SHAPEMODE_CENTER) + { xp = (x1 + offx) * cos(rotn_rad) - (y1 + offy) * sin(rotn_rad); yp = (x1 + offx) * sin(rotn_rad) + (y1 + offy) * cos(rotn_rad); @@ -16386,7 +15743,9 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 xv = xp - offx; yv = yp - offy; - } else { + } + else + { xp = x1 * cos(rotn_rad) - y1 * sin(rotn_rad); yp = x1 * sin(rotn_rad) + y1 * cos(rotn_rad); @@ -16454,8 +15813,8 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 for (side = 0; side < shape_sides[cur_shape]; side++) { - a1 = (angle_skip * (float) side + init_ang) * M_PI / 180.0; - a2 = (angle_skip * ((float) side + 1.0) + init_ang) * M_PI / 180.0; + a1 = (angle_skip * (float)side + init_ang) * M_PI / 180.0; + a2 = (angle_skip * ((float)side + 1.0) + init_ang) * M_PI / 180.0; if (yy == xx * ry / rx) { @@ -16486,7 +15845,8 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 { rotn_rad = rotn * M_PI / 180; - if (shape_mode == SHAPEMODE_CENTER) { + if (shape_mode == SHAPEMODE_CENTER) + { xp = (x1 + offx) * cos(rotn_rad) - (y1 + offy) * sin(rotn_rad); yp = (x1 + offx) * sin(rotn_rad) + (y1 + offy) * cos(rotn_rad); @@ -16504,7 +15864,9 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 xv = xp - offx; yv = yp - offy; - } else { + } + else + { xp = x1 * cos(rotn_rad) - y1 * sin(rotn_rad); yp = x1 * sin(rotn_rad) + y1 * cos(rotn_rad); @@ -16548,8 +15910,7 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 } if (xx % 10 == 0) - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, - (button_h * 7) + 40 + HEIGHTOFFSET); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, (button_h * 7) + 40 + HEIGHTOFFSET); } } @@ -16563,8 +15924,7 @@ printf("side=%d, a1=%f, a2=%f -- (%f,%f) -> (%f,%f)\n", side, a1, a2, x1, y1, x2 else rmax = abs(ry) + 20; - update_canvas(sx - rmax + offx, sy - rmax + offy, sx + rmax + offx, - sy + rmax + offy); + update_canvas(sx - rmax + offx, sy - rmax + offy, sx + rmax + offx, sy + rmax + offy); } @@ -16669,8 +16029,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) if (disable_save && !autosave) return 0; - scroll = - (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; + scroll = (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; tmp_apply_uncommited_text(); SDL_BlitSurface(canvas, NULL, save_canvas, NULL); @@ -16700,9 +16059,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) img_save_over, NULL, NULL, SND_AREYOUSURE, (TOOL_SAVE % 2) * button_w + button_w / 2, (TOOL_SAVE / 2) * button_h + r_ttools.h + - button_h / 2 - - tool_scroll * button_h / gd_tools.cols + - scroll) == 0) + button_h / 2 - tool_scroll * button_h / gd_tools.cols + scroll) == 0) { /* No - Let's save a new picture! */ @@ -16733,8 +16090,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) do_setcursor(cursor_watch); } - if (!make_directory - (DIR_SAVE, "", "Can't create user data directory (E002)")) + if (!make_directory(DIR_SAVE, "", "Can't create user data directory (E002)")) { fprintf(stderr, "Cannot save the any pictures! SORRY!\n\n"); draw_tux_text(TUX_OOPS, strerror(errno), 0); @@ -16749,9 +16105,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) /* Make sure we have a ~/.tuxpaint/saved directory: */ - if (!make_directory - (DIR_SAVE, "saved", - "Can't create user data directory (for saved drawings) (E003)")) + if (!make_directory(DIR_SAVE, "saved", "Can't create user data directory (for saved drawings) (E003)")) { fprintf(stderr, "Cannot save any pictures! SORRY!\n\n"); draw_tux_text(TUX_OOPS, strerror(errno), 0); @@ -16767,8 +16121,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) /* Make sure we have a ~/.tuxpaint/saved/.thumbs/ directory: */ if (!make_directory - (DIR_SAVE, "saved/.thumbs", - "Can't create user data thumbnail directory (for saved drawings' thumbnails) (E004)")) + (DIR_SAVE, "saved/.thumbs", "Can't create user data thumbnail directory (for saved drawings' thumbnails) (E004)")) { fprintf(stderr, "Cannot save any pictures! SORRY!\n\n"); draw_tux_text(TUX_OOPS, strerror(errno), 0); @@ -16777,9 +16130,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) - if (!make_directory - (DIR_SAVE, "saved/.label", - "Can't create label information directory (E005)")) + if (!make_directory(DIR_SAVE, "saved/.label", "Can't create label information directory (E005)")) { fprintf(stderr, "Cannot save label information! SORRY!\n\n"); draw_tux_text(TUX_OOPS, strerror(errno), 0); @@ -16806,8 +16157,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) { fprintf(stderr, "\nError: Couldn't save the current image!\n" - "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, - strerror(errno)); + "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, strerror(errno)); draw_tux_text(TUX_OOPS, strerror(errno), 0); } @@ -16846,8 +16196,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) /* No old thumbnail! Save this image's thumbnail in the new place, under ".thumbs" */ - safe_snprintf(tmp, sizeof(tmp), "saved/.thumbs/%s-t%s", file_id, - FNAME_EXTENSION); + safe_snprintf(tmp, sizeof(tmp), "saved/.thumbs/%s-t%s", file_id, FNAME_EXTENSION); fname = get_fname(tmp, DIR_SAVE); } @@ -16859,8 +16208,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) if (fi == NULL) { fprintf(stderr, "\nError: Couldn't save thumbnail of image!\n" - "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, - strerror(errno)); + "%s\n" "The system error that occurred was:\n" "%s\n\n", fname, strerror(errno)); } else { @@ -16874,8 +16222,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) /* Write 'starter' and/or canvas color info, if it's useful to: */ if (starter_id[0] != '\0' || - template_id[0] != '\0' || canvas_color_r != 255 || canvas_color_g != 255 - || canvas_color_b != 255) + template_id[0] != '\0' || canvas_color_r != 255 || canvas_color_g != 255 || canvas_color_b != 255) { safe_snprintf(tmp, sizeof(tmp), "saved/%s.dat", file_id); fname = get_fname(tmp, DIR_SAVE); @@ -16883,10 +16230,8 @@ static int do_save(int tool, int dont_show_success_results, int autosave) if (fi != NULL) { fprintf(fi, "%s\n", starter_id); - fprintf(fi, "%d %d %d\n", starter_mirrored, starter_flipped, - starter_personal); - fprintf(fi, "c%d %d %d\n", canvas_color_r, canvas_color_g, - canvas_color_b); + fprintf(fi, "%d %d %d\n", starter_mirrored, starter_flipped, starter_personal); + fprintf(fi, "c%d %d %d\n", canvas_color_r, canvas_color_g, canvas_color_b); fprintf(fi, "T%s\n", template_id); fprintf(fi, "%d\n", template_personal); fclose(fi); @@ -16915,8 +16260,7 @@ static int do_save(int tool, int dont_show_success_results, int autosave) * FIXME */ static void set_chunk_data(unsigned char **chunk_data, size_t *chunk_data_len, - size_t uncompressed_size, Bytef * data, - size_t dataLen) + size_t uncompressed_size, Bytef * data, size_t dataLen) { int headersLen; unsigned int i; @@ -16944,7 +16288,7 @@ static void set_chunk_data(unsigned char **chunk_data, size_t *chunk_data_len, for (i = 0; i < dataLen; i++) cdata[headersLen + i] = data[i]; - *chunk_data = (unsigned char *) cdata; + *chunk_data = (unsigned char *)cdata; free(line); free(headers); @@ -17003,6 +16347,7 @@ static void do_png_embed_data(png_structp png_ptr) struct label_node *current_node; char *char_stream, *line; size_t dat_size, char_stream_sz, line_sz; + #ifdef WIN32 wchar_t wtmpchar; char tmpstr[16]; @@ -17012,7 +16357,7 @@ static void do_png_embed_data(png_structp png_ptr) /* Starter foreground */ if (img_starter) { - DEBUG_PRINTF("Saving starter... %d\n", (int) (intptr_t) img_starter); //EP added (intptr_t) to avoid warning on x64 + DEBUG_PRINTF("Saving starter... %d\n", (int)(intptr_t) img_starter); //EP added (intptr_t) to avoid warning on x64 sbk_pixs = malloc(img_starter->h * img_starter->w * 4); compressedLen = compressBound(img_starter->h * img_starter->w * 4); @@ -17048,11 +16393,8 @@ static void do_png_embed_data(png_structp png_ptr) if (SDL_MUSTLOCK(img_starter)) SDL_UnlockSurface(img_starter); - compress(compressed_data, &compressedLen, sbk_pixs, - img_starter->h * img_starter->w * 4); - set_chunk_data(&chunk_data, &chunk_data_len, - img_starter->w * img_starter->h * 4, compressed_data, - compressedLen); + compress(compressed_data, &compressedLen, sbk_pixs, img_starter->h * img_starter->w * 4); + set_chunk_data(&chunk_data, &chunk_data_len, img_starter->w * img_starter->h * 4, compressed_data, compressedLen); tuxpaint_chunks[1].data = (png_byte *) chunk_data; tuxpaint_chunks[1].size = chunk_data_len; @@ -17062,8 +16404,7 @@ static void do_png_embed_data(png_structp png_ptr) tuxpaint_chunks[1].name[2] = 'F'; tuxpaint_chunks[1].name[3] = 'G'; tuxpaint_chunks[1].name[4] = '\0'; - png_write_chunk(png_ptr, tuxpaint_chunks[1].name, tuxpaint_chunks[1].data, - tuxpaint_chunks[1].size); + png_write_chunk(png_ptr, tuxpaint_chunks[1].name, tuxpaint_chunks[1].data, tuxpaint_chunks[1].size); free(compressed_data); free(chunk_data); @@ -17074,8 +16415,7 @@ static void do_png_embed_data(png_structp png_ptr) if (img_starter_bkgd) { sbk_pixs = malloc(img_starter_bkgd->w * img_starter_bkgd->h * 3); - compressedLen = - compressBound(img_starter_bkgd->h * img_starter_bkgd->w * 3); + compressedLen = compressBound(img_starter_bkgd->h * img_starter_bkgd->w * 3); compressed_data = malloc(compressedLen * sizeof(Bytef *)); @@ -17086,8 +16426,7 @@ static void do_png_embed_data(png_structp png_ptr) for (x = 0; x < img_starter_bkgd->w; x++) { SDL_GetRGB(getpixels[img_starter_bkgd->format->BytesPerPixel] - (img_starter_bkgd, x, y), img_starter_bkgd->format, &r, &g, - &b); + (img_starter_bkgd, x, y), img_starter_bkgd->format, &r, &g, &b); sbk_pixs[3 * (y * img_starter_bkgd->w + x)] = r; sbk_pixs[3 * (y * img_starter_bkgd->w + x) + 1] = g; @@ -17103,17 +16442,13 @@ static void do_png_embed_data(png_structp png_ptr) for (x = 0; x < img_starter_bkgd->w; x++) { SDL_GetRGBA(getpixels[img_starter->format->BytesPerPixel] - (img_starter, x, y), img_starter->format, &r, &g, &b, - &a); + (img_starter, x, y), img_starter->format, &r, &g, &b, &a); if (a == SDL_ALPHA_OPAQUE) { - sbk_pixs[3 * (y * img_starter_bkgd->w + x)] = - SDL_ALPHA_TRANSPARENT; - sbk_pixs[3 * (y * img_starter_bkgd->w + x) + 1] = - SDL_ALPHA_TRANSPARENT; - sbk_pixs[3 * (y * img_starter_bkgd->w + x) + 2] = - SDL_ALPHA_TRANSPARENT; + sbk_pixs[3 * (y * img_starter_bkgd->w + x)] = SDL_ALPHA_TRANSPARENT; + sbk_pixs[3 * (y * img_starter_bkgd->w + x) + 1] = SDL_ALPHA_TRANSPARENT; + sbk_pixs[3 * (y * img_starter_bkgd->w + x) + 2] = SDL_ALPHA_TRANSPARENT; } } if (SDL_MUSTLOCK(img_starter)) @@ -17123,16 +16458,14 @@ static void do_png_embed_data(png_structp png_ptr) if (SDL_MUSTLOCK(img_starter_bkgd)) SDL_UnlockSurface(img_starter_bkgd); - DEBUG_PRINTF("%d \n", (int) compressedLen); + DEBUG_PRINTF("%d \n", (int)compressedLen); - compress(compressed_data, &compressedLen, sbk_pixs, - img_starter_bkgd->h * img_starter_bkgd->w * 3); + compress(compressed_data, &compressedLen, sbk_pixs, img_starter_bkgd->h * img_starter_bkgd->w * 3); set_chunk_data(&chunk_data, &chunk_data_len, - img_starter_bkgd->w * img_starter_bkgd->h * 3, - compressed_data, compressedLen); + img_starter_bkgd->w * img_starter_bkgd->h * 3, compressed_data, compressedLen); - DEBUG_PRINTF("%d \n", (int) compressedLen); + DEBUG_PRINTF("%d \n", (int)compressedLen); tuxpaint_chunks[2].data = (png_byte *) chunk_data; @@ -17143,8 +16476,7 @@ static void do_png_embed_data(png_structp png_ptr) tuxpaint_chunks[2].name[2] = 'B'; tuxpaint_chunks[2].name[3] = 'G'; tuxpaint_chunks[2].name[4] = '\0'; - png_write_chunk(png_ptr, tuxpaint_chunks[2].name, tuxpaint_chunks[2].data, - tuxpaint_chunks[2].size); + png_write_chunk(png_ptr, tuxpaint_chunks[2].name, tuxpaint_chunks[2].data, tuxpaint_chunks[2].size); free(compressed_data); free(chunk_data); @@ -17167,12 +16499,10 @@ static void do_png_embed_data(png_structp png_ptr) { for (x = 0; x < label->w; x++) { - SDL_GetRGBA(getpixels[label->format->BytesPerPixel] (label, x, y), - label->format, &r, &g, &b, &a); + SDL_GetRGBA(getpixels[label->format->BytesPerPixel] (label, x, y), label->format, &r, &g, &b, &a); if (a != SDL_ALPHA_TRANSPARENT) { - SDL_GetRGB(getpixels[canvas->format->BytesPerPixel] (canvas, x, y), - canvas->format, &r, &g, &b); + SDL_GetRGB(getpixels[canvas->format->BytesPerPixel] (canvas, x, y), canvas->format, &r, &g, &b); sbk_pixs[4 * (y * label->w + x)] = r; sbk_pixs[4 * (y * label->w + x) + 1] = g; @@ -17194,10 +16524,8 @@ static void do_png_embed_data(png_structp png_ptr) if (SDL_MUSTLOCK(canvas)) SDL_UnlockSurface(canvas); - compress(compressed_data, &compressedLen, sbk_pixs, - canvas->h * canvas->w * 4); - set_chunk_data(&chunk_data, &chunk_data_len, canvas->w * canvas->h * 4, - compressed_data, compressedLen); + compress(compressed_data, &compressedLen, sbk_pixs, canvas->h * canvas->w * 4); + set_chunk_data(&chunk_data, &chunk_data_len, canvas->w * canvas->h * 4, compressed_data, compressedLen); tuxpaint_chunks[3].data = chunk_data; tuxpaint_chunks[3].size = chunk_data_len; @@ -17208,8 +16536,7 @@ static void do_png_embed_data(png_structp png_ptr) tuxpaint_chunks[3].name[3] = 'D'; tuxpaint_chunks[3].name[4] = '\0'; - png_write_chunk(png_ptr, tuxpaint_chunks[3].name, tuxpaint_chunks[3].data, - tuxpaint_chunks[3].size); + png_write_chunk(png_ptr, tuxpaint_chunks[3].name, tuxpaint_chunks[3].data, tuxpaint_chunks[3].size); free(compressed_data); free(chunk_data); free(sbk_pixs); @@ -17246,21 +16573,18 @@ static void do_png_embed_data(png_structp png_ptr) current_node = start_label_node; while (current_node && current_node != first_label_node_in_redo_stack) { - if (current_node->is_enabled == TRUE - && current_node->save_texttool_len > 0) + if (current_node->is_enabled == TRUE && current_node->save_texttool_len > 0) { fprintf(lfi, "%u\n", current_node->save_texttool_len); for (i = 0; i < current_node->save_texttool_len; i++) { #ifdef WIN32 wtmpchar = current_node->save_texttool_str[i]; - nbtmpstr = - WideCharToMultiByte(CP_UTF8, 0, &wtmpchar, 1, tmpstr, 16, NULL, - NULL); + nbtmpstr = WideCharToMultiByte(CP_UTF8, 0, &wtmpchar, 1, tmpstr, 16, NULL, NULL); tmpstr[nbtmpstr] = '\0'; fprintf(lfi, "%s", tmpstr); #elif defined(__ANDROID__) - fprintf(lfi, "%d ", (int) current_node->save_texttool_str[i]); + fprintf(lfi, "%d ", (int)current_node->save_texttool_str[i]); #else fprintf(lfi, "%lc", (wint_t) current_node->save_texttool_str[i]); #endif @@ -17278,10 +16602,7 @@ static void do_png_embed_data(png_structp png_ptr) if (current_node->save_font_type == NULL) /* Fonts yet setted */ { fprintf(lfi, "%d\n", current_node->save_cur_font); - fprintf(lfi, "%s\n", - TTF_FontFaceFamilyName(getfonthandle - (current_node->save_cur_font)-> - ttf_font)); + fprintf(lfi, "%s\n", TTF_FontFaceFamilyName(getfonthandle(current_node->save_cur_font)->ttf_font)); } else { @@ -17300,8 +16621,7 @@ static void do_png_embed_data(png_structp png_ptr) /* *INDENT-OFF* */ pix = getpixels[current_node->label_node_surface->format->BytesPerPixel](current_node->label_node_surface, x, y); /* *INDENT-ON* */ - SDL_GetRGBA(pix, current_label_node->label_node_surface->format, - &r, &g, &b, &a); + SDL_GetRGBA(pix, current_label_node->label_node_surface->format, &r, &g, &b, &a); fwrite(&a, alpha_size, 1, lfi); } SDL_UnlockSurface(current_node->label_node_surface); @@ -17324,11 +16644,8 @@ static void do_png_embed_data(png_structp png_ptr) compressedLen = compressBound(size_of_uncompressed_label_data); compressed_data = malloc(compressedLen * sizeof(Bytef *)); - compress((Bytef *) compressed_data, &compressedLen, - (unsigned char *) ldata, size_of_uncompressed_label_data); - set_chunk_data(&chunk_data, &chunk_data_len, - size_of_uncompressed_label_data, compressed_data, - compressedLen); + compress((Bytef *) compressed_data, &compressedLen, (unsigned char *)ldata, size_of_uncompressed_label_data); + set_chunk_data(&chunk_data, &chunk_data_len, size_of_uncompressed_label_data, compressed_data, compressedLen); tuxpaint_chunks[4].data = chunk_data; tuxpaint_chunks[4].size = chunk_data_len; @@ -17339,8 +16656,7 @@ static void do_png_embed_data(png_structp png_ptr) tuxpaint_chunks[4].name[3] = 'L'; tuxpaint_chunks[4].name[4] = '\0'; - png_write_chunk(png_ptr, tuxpaint_chunks[4].name, tuxpaint_chunks[4].data, - tuxpaint_chunks[4].size); + png_write_chunk(png_ptr, tuxpaint_chunks[4].name, tuxpaint_chunks[4].data, tuxpaint_chunks[4].size); free(compressed_data); free(chunk_data); @@ -17350,23 +16666,19 @@ static void do_png_embed_data(png_structp png_ptr) /* Write 'starter' and/or canvas color info, if it's useful to: */ if (starter_id[0] != '\0' || - template_id[0] != '\0' || canvas_color_r != 255 || canvas_color_g != 255 - || canvas_color_b != 255) + template_id[0] != '\0' || canvas_color_r != 255 || canvas_color_g != 255 || canvas_color_b != 255) { /* Usually the .dat data are less than 100 bytes, hope this keeps line and char_stream in the safe side */ line_sz = 256; line = calloc(line_sz, 1); - char_stream_sz = 256 + sizeof(starter_id) + sizeof(template_id), - char_stream = calloc(char_stream_sz, 1); + char_stream_sz = 256 + sizeof(starter_id) + sizeof(template_id), char_stream = calloc(char_stream_sz, 1); safe_snprintf(char_stream, char_stream_sz, "%s\n", starter_id); - safe_snprintf(line, line_sz, "%d %d %d\n", starter_mirrored, - starter_flipped, starter_personal); + safe_snprintf(line, line_sz, "%d %d %d\n", starter_mirrored, starter_flipped, starter_personal); safe_strncat(char_stream, line, char_stream_sz); - safe_snprintf(line, line_sz, "c%d %d %d\n", canvas_color_r, - canvas_color_g, canvas_color_b); + safe_snprintf(line, line_sz, "c%d %d %d\n", canvas_color_r, canvas_color_g, canvas_color_b); safe_strncat(char_stream, line, char_stream_sz); safe_snprintf(line, line_sz, "T%s\n", template_id); @@ -17380,8 +16692,7 @@ static void do_png_embed_data(png_structp png_ptr) dat_size = strlen(char_stream); - set_chunk_data(&chunk_data, &chunk_data_len, dat_size, - (Bytef *) char_stream, dat_size); + set_chunk_data(&chunk_data, &chunk_data_len, dat_size, (Bytef *) char_stream, dat_size); tuxpaint_chunks[4].data = chunk_data; tuxpaint_chunks[4].size = chunk_data_len; @@ -17392,8 +16703,7 @@ static void do_png_embed_data(png_structp png_ptr) tuxpaint_chunks[4].name[3] = 'T'; tuxpaint_chunks[4].name[4] = '\0'; - png_write_chunk(png_ptr, tuxpaint_chunks[4].name, tuxpaint_chunks[4].data, - tuxpaint_chunks[4].size); + png_write_chunk(png_ptr, tuxpaint_chunks[4].name, tuxpaint_chunks[4].data, tuxpaint_chunks[4].size); free(char_stream); free(line); @@ -17405,8 +16715,7 @@ static void do_png_embed_data(png_structp png_ptr) * FIXME */ /* Actually save the PNG data to the file stream: */ -static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, - int embed) +static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, int embed) { png_structp png_ptr; png_infop info_ptr; @@ -17415,8 +16724,7 @@ static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, Uint8 r, g, b; int x, y, count; - Uint32(*getpixel) (SDL_Surface *, int, int) = - getpixels[surf->format->BytesPerPixel]; + Uint32(*getpixel) (SDL_Surface *, int, int) = getpixels[surf->format->BytesPerPixel]; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -17456,11 +16764,9 @@ static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, png_init_io(png_ptr, fi); png_set_IHDR(png_ptr, info_ptr, surf->w, surf->h, 8, - PNG_COLOR_TYPE_RGB, 1, PNG_COMPRESSION_TYPE_BASE, - PNG_FILTER_TYPE_BASE); + PNG_COLOR_TYPE_RGB, 1, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - PNG_sRGB_INTENT_PERCEPTUAL); + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); /* Set headers */ @@ -17477,8 +16783,7 @@ static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf, */ text_ptr[count].key = (png_charp) "Software"; - text_ptr[count].text = - (png_charp) "Tux Paint " VER_VERSION " (" VER_DATE ")"; + text_ptr[count].text = (png_charp) "Tux Paint " VER_VERSION " (" VER_DATE ")"; text_ptr[count].compression = PNG_TEXT_COMPRESSION_NONE; count++; @@ -17556,8 +16861,7 @@ static int do_quit(int tool) if (!no_prompt_on_quit) { - scroll = - (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; + scroll = (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; done = do_prompt_snd(PROMPT_QUIT_TXT, PROMPT_QUIT_YES, PROMPT_QUIT_NO, SND_AREYOUSURE, (TOOL_QUIT % 2) * button_w + button_w / 2, @@ -17572,8 +16876,7 @@ static int do_quit(int tool) if (done && !been_saved && !disable_save) { if (autosave_on_quit || - do_prompt(PROMPT_QUIT_SAVE_TXT, PROMPT_QUIT_SAVE_YES, - PROMPT_QUIT_SAVE_NO, screen->w / 2, screen->h / 2)) + do_prompt(PROMPT_QUIT_SAVE_TXT, PROMPT_QUIT_SAVE_YES, PROMPT_QUIT_SAVE_NO, screen->w / 2, screen->h / 2)) { if (do_save(tool, 1, 0)) { @@ -17663,7 +16966,7 @@ static int do_open(void) things_alloced = 32; - fs = (struct dirent2 *) malloc(sizeof(struct dirent2) * things_alloced); + fs = (struct dirent2 *)malloc(sizeof(struct dirent2) * things_alloced); num_files = 0; cur = 0; @@ -17675,8 +16978,7 @@ static int do_open(void) /* Open directories of images: */ - for (places_to_look = 0; places_to_look < NUM_PLACES_TO_LOOK; - places_to_look++) + for (places_to_look = 0; places_to_look < NUM_PLACES_TO_LOOK; places_to_look++) { if (places_to_look == PLACE_SAVED_DIR) { @@ -17737,10 +17039,7 @@ static int do_open(void) things_alloced = things_alloced + 32; /* FIXME: Valgrind says this is leaked -bjk 2007.07.19 */ - fs = - (struct dirent2 *) realloc(fs, - sizeof(struct dirent2) * - things_alloced); + fs = (struct dirent2 *)realloc(fs, sizeof(struct dirent2) * things_alloced); } } } @@ -17753,21 +17052,19 @@ static int do_open(void) /* (Re)allocate space for the information about these files: */ - thumbs = - (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * num_files_in_dirs); - d_places = (int *) malloc(sizeof(int) * num_files_in_dirs); - d_names = (char **) malloc(sizeof(char *) * num_files_in_dirs); - d_exts = (char **) malloc(sizeof(char *) * num_files_in_dirs); + thumbs = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * num_files_in_dirs); + d_places = (int *)malloc(sizeof(int) * num_files_in_dirs); + d_names = (char **)malloc(sizeof(char *) * num_files_in_dirs); + d_exts = (char **)malloc(sizeof(char *) * num_files_in_dirs); /* Sort: */ if (!reversesort) - qsort(fs, num_files_in_dirs, sizeof(struct dirent2), - (int (*)(const void *, const void *)) compare_dirent2s); + qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s); else qsort(fs, num_files_in_dirs, sizeof(struct dirent2), - (int (*)(const void *, const void *)) compare_dirent2s_invert); + (int (*)(const void *, const void *))compare_dirent2s_invert); /* Read directory of images and build thumbnails: */ @@ -17783,8 +17080,7 @@ static int do_open(void) { debug(f->d_name); - if (strcasestr(f->d_name, "-t.") == NULL - && strcasestr(f->d_name, "-back.") == NULL) + if (strcasestr(f->d_name, "-t.") == NULL && strcasestr(f->d_name, "-back.") == NULL) { if (strcasestr(f->d_name, FNAME_EXTENSION) != NULL /* Support legacy BMP files for load: */ @@ -17794,13 +17090,13 @@ static int do_open(void) if (strcasestr(fname, FNAME_EXTENSION) != NULL) { d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION)); - strcpy((char *) strcasestr(fname, FNAME_EXTENSION), ""); /* Safe; truncating */ + strcpy((char *)strcasestr(fname, FNAME_EXTENSION), ""); /* Safe; truncating */ } if (strcasestr(fname, ".bmp") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".bmp")); - strcpy((char *) strcasestr(fname, ".bmp"), ""); /* Safe; truncating */ + strcpy((char *)strcasestr(fname, ".bmp"), ""); /* Safe; truncating */ } d_names[num_files] = strdup(fname); @@ -17837,8 +17133,7 @@ static int do_open(void) /* No thumbnail in the new location ("saved/.thumbs"), try the old locatin ("saved/"): */ - safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", - dirname[d_places[num_files]], d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", dirname[d_places[num_files]], d_names[num_files]); debug(fname); img = IMG_Load(fname); @@ -17866,9 +17161,7 @@ static int do_open(void) if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of " - "saved image!\n" "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of " "saved image!\n" "%s\n", fname); } num_files++; @@ -17878,9 +17171,7 @@ static int do_open(void) /* No thumbnail - load original: */ /* Make sure we have a ~/.tuxpaint/saved directory: */ - if (make_directory - (DIR_SAVE, "saved", - "Can't create user data directory (for saved drawings) (E006)")) + if (make_directory(DIR_SAVE, "saved", "Can't create user data directory (for saved drawings) (E006)")) { /* (Make sure we have a .../saved/.thumbs/ directory:) */ make_directory(DIR_SAVE, "saved/.thumbs", @@ -17890,8 +17181,7 @@ static int do_open(void) if (img == NULL) { - safe_snprintf(fname, sizeof(fname), "%s/%s", - dirname[d_places[num_files]], f->d_name); + safe_snprintf(fname, sizeof(fname), "%s/%s", dirname[d_places[num_files]], f->d_name); debug(fname); img = myIMG_Load(fname); } @@ -17904,8 +17194,7 @@ static int do_open(void) fprintf(stderr, "\nWarning: I can't open one of the saved files!\n" "%s\n" - "The Simple DirectMedia Layer error that " - "occurred was:\n" "%s\n\n", fname, SDL_GetError()); + "The Simple DirectMedia Layer error that " "occurred was:\n" "%s\n\n", fname, SDL_GetError()); free(d_names[num_files]); free(d_exts[num_files]); @@ -17924,9 +17213,7 @@ static int do_open(void) SDL_FreeSurface(img2); if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of " - "saved image!\n" "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of " "saved image!\n" "%s\n", fname); } SDL_FreeSurface(img); @@ -17942,17 +17229,14 @@ static int do_open(void) debug("Saving thumbnail for this one!"); safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", - dirname[d_places[num_files]], - d_names[num_files]); + dirname[d_places[num_files]], d_names[num_files]); fi = fopen(fname, "wb"); if (fi == NULL) { fprintf(stderr, "\nError: Couldn't save thumbnail of " - "saved image!\n" - "%s\n" "The error that occurred was:\n" "%s\n\n", - fname, strerror(errno)); + "saved image!\n" "%s\n" "The error that occurred was:\n" "%s\n\n", fname, strerror(errno)); } else { @@ -17984,17 +17268,15 @@ static int do_open(void) do_prompt_snd(PROMPT_OPEN_NOFILES_TXT, PROMPT_OPEN_NOFILES_YES, "", SND_YOUCANNOT, (TOOL_OPEN % 2) * button_w + button_w / 2, - (TOOL_OPEN / 2) * button_h + r_ttools.h + button_h / 2 - - tool_scroll * button_h / gd_tools.cols); + (TOOL_OPEN / 2) * button_h + r_ttools.h + button_h / 2 - tool_scroll * button_h / gd_tools.cols); } else { /* Let user choose an image: */ /* Instructions for 'Open' file dialog */ - char *instructions = - textdir(gettext_noop - ("Choose the picture you want, then click “Open”.")); + char *instructions = textdir(gettext_noop("Choose the picture you want, then click “Open”.")); + draw_tux_text(TUX_BORED, instructions, 1); /* NOTE: cur is now set above; if file_id'th file is found, it's @@ -18028,8 +17310,7 @@ static int do_open(void) dest.w = WINDOW_WIDTH - r_ttoolopt.w - r_ttools.w; dest.h = button_h * buttons_tall + r_ttools.h; - SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255)); /* Draw icons: */ @@ -18051,16 +17332,8 @@ static int do_open(void) - dest.x = - THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - - thumbs[i]->w) / - 2; - dest.y = - THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - - 20 - - thumbs - [i]->h) / - 2; + dest.x = THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - thumbs[i]->w) / 2; + dest.y = THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - 20 - thumbs[i]->h) / 2; if (thumbs[i] != NULL) SDL_BlitSurface(thumbs[i], NULL, screen, &dest); @@ -18093,8 +17366,7 @@ static int do_open(void) SDL_BlitSurface(img_open, NULL, screen, &dest); dest.x = r_ttools.w + (button_w - img_openlabels_open->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_open->h; // FIXME: CROP LABELS + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_open->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_open, NULL, screen, &dest); @@ -18111,12 +17383,8 @@ static int do_open(void) dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_slideshow, NULL, screen, &dest); - dest.x = - r_ttools.w + button_w + (button_w - - img_openlabels_slideshow->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - - img_openlabels_slideshow->h; // FIXME: CROP LABELS + dest.x = r_ttools.w + button_w + (button_w - img_openlabels_slideshow->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_slideshow->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_slideshow, NULL, screen, &dest); @@ -18126,39 +17394,29 @@ static int do_open(void) dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_back, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - - img_openlabels_back->w) - / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - img_openlabels_back->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_back, NULL, screen, &dest); /* "Export" button: */ - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - button_w; + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - button_w; dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; - if (d_places[which] != PLACE_STARTERS_DIR - && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) + if (d_places[which] != PLACE_STARTERS_DIR && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) SDL_BlitSurface(img_btn_up, NULL, screen, &dest); else SDL_BlitSurface(img_btn_off, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - button_w + - (button_w - img_pict_export->w) / 2; + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - button_w + (button_w - img_pict_export->w) / 2; dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_pict_export, NULL, screen, &dest); dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - button_w + (button_w - img_openlabels_pict_export->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - - img_openlabels_pict_export->h; // FIXME: CROP LABELS + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_pict_export->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_pict_export, NULL, screen, &dest); @@ -18167,18 +17425,13 @@ static int do_open(void) dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w; dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; - if (d_places[which] != PLACE_STARTERS_DIR - && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) + if (d_places[which] != PLACE_STARTERS_DIR && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) SDL_BlitSurface(img_erase, NULL, screen, &dest); else SDL_BlitSurface(img_btn_off, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w + (button_w - - img_openlabels_erase-> - w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_erase->h; // FIXME: CROP LABELS + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w + (button_w - img_openlabels_erase->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_erase->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_erase, NULL, screen, &dest); @@ -18285,8 +17538,7 @@ static int do_open(void) else if (key == SDLK_d && (event.key.keysym.mod & KMOD_CTRL) && d_places[which] != PLACE_STARTERS_DIR && - d_places[which] != PLACE_PERSONAL_STARTERS_DIR - && !noshortcuts) + d_places[which] != PLACE_PERSONAL_STARTERS_DIR && !noshortcuts) { /* Delete! */ @@ -18295,14 +17547,12 @@ static int do_open(void) } else if ((event.type == SDL_MOUSEBUTTONDOWN - && valid_click(event.button.button)) - || event.type == TP_SDL_MOUSEBUTTONSCROLL) + && valid_click(event.button.button)) || event.type == TP_SDL_MOUSEBUTTONSCROLL) { if (event.button.x >= r_ttools.w && event.button.x < WINDOW_WIDTH - r_ttoolopt.w && event.button.y >= img_scroll_up->h - && event.button.y < - (button_h * buttons_tall + r_ttools.h) - button_h) + && event.button.y < (button_h * buttons_tall + r_ttools.h) - button_h) { /* Picked an icon! */ @@ -18314,14 +17564,12 @@ static int do_open(void) if (which < num_files) { - playsound(screen, 1, SND_BLEEP, 1, event.button.x, - SNDDIST_NEAR); + playsound(screen, 1, SND_BLEEP, 1, event.button.x, SNDDIST_NEAR); update_list = 1; if (which == last_click_which && - SDL_GetTicks() < last_click_time + 1000 - && event.button.button == last_click_button) + SDL_GetTicks() < last_click_time + 1000 && event.button.button == last_click_button) { /* Double-click! */ @@ -18336,14 +17584,12 @@ static int do_open(void) which = old_which; } else if (event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 - && event.button.x <= - (WINDOW_WIDTH + img_scroll_up->w) / 2) + && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2) { if (event.button.y < img_scroll_up->h || (event.button.y >= (button_h * buttons_tall + r_ttools.h) - button_h - && event.button.y < - (button_h * buttons_tall + r_ttools.h) - img_scroll_up->h)) + && event.button.y < (button_h * buttons_tall + r_ttools.h) - img_scroll_up->h)) { /* Up or down scroll button in Open dialog: */ @@ -18355,8 +17601,7 @@ static int do_open(void) { cur = cur - 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur == 0) do_setcursor(cursor_arrow); @@ -18367,9 +17612,7 @@ static int do_open(void) } else if (event.button.y >= (button_h * buttons_tall + r_ttools.h) - button_h - && event.button.y < - (button_h * buttons_tall + r_ttools.h) - - img_scroll_up->h) + && event.button.y < (button_h * buttons_tall + r_ttools.h) - img_scroll_up->h) { /* Down scroll button in Open dialog: */ @@ -18377,8 +17620,7 @@ static int do_open(void) { cur = cur + 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur >= num_files - 16) do_setcursor(cursor_arrow); @@ -18397,22 +17639,18 @@ static int do_open(void) if (!scrolling_dialog && event.type == SDL_MOUSEBUTTONDOWN) { DEBUG_PRINTF("Starting scrolling\n"); - memcpy(&scrolltimer_dialog_event, &event, - sizeof(SDL_Event)); + memcpy(&scrolltimer_dialog_event, &event, sizeof(SDL_Event)); scrolltimer_dialog_event.type = TP_SDL_MOUSEBUTTONSCROLL; scrolling_dialog = 1; scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } else { DEBUG_PRINTF("Continuing scrolling\n"); scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED / 3, - scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } } } @@ -18420,8 +17658,7 @@ static int do_open(void) && event.button.x < r_ttools.w + button_w && event.button.y >= (button_h * buttons_tall + r_ttools.h) - button_h - && event.button.y < - (button_h * buttons_tall + r_ttools.h)) + && event.button.y < (button_h * buttons_tall + r_ttools.h)) { /* Open */ @@ -18432,9 +17669,7 @@ static int do_open(void) && event.button.x < r_ttools.w + button_w + button_w && event.button.y >= (button_h * buttons_tall + r_ttools.h) - button_h - && event.button.y < - (button_h * buttons_tall + r_ttools.h) - && any_saved_files == 1) + && event.button.y < (button_h * buttons_tall + r_ttools.h) && any_saved_files == 1) { /* Slideshow */ @@ -18447,8 +17682,7 @@ static int do_open(void) && event.button.x < (WINDOW_WIDTH - r_ttoolopt.w) && event.button.y >= (button_h * buttons_tall + r_ttools.h) - button_h - && event.button.y < - (button_h * buttons_tall + r_ttools.h)) + && event.button.y < (button_h * buttons_tall + r_ttools.h)) { /* Back */ @@ -18464,8 +17698,7 @@ static int do_open(void) (button_h * buttons_tall + r_ttools.h) - button_h && event.button.y < (button_h * buttons_tall + r_ttools.h) - && d_places[which] != PLACE_STARTERS_DIR - && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) + && d_places[which] != PLACE_STARTERS_DIR && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) { /* Erase */ @@ -18480,8 +17713,7 @@ static int do_open(void) (button_h * buttons_tall + r_ttools.h) - button_h && event.button.y < (button_h * buttons_tall + r_ttools.h) - && d_places[which] != PLACE_STARTERS_DIR - && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) + && d_places[which] != PLACE_STARTERS_DIR && d_places[which] != PLACE_PERSONAL_STARTERS_DIR) { /* Export */ @@ -18499,8 +17731,7 @@ static int do_open(void) { cur = cur - 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur == 0) do_setcursor(cursor_arrow); @@ -18512,8 +17743,7 @@ static int do_open(void) { cur = cur + 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur >= num_files - 16) do_setcursor(cursor_arrow); @@ -18528,8 +17758,7 @@ static int do_open(void) if (event.button.y < img_scroll_up->h && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 && - event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur > 0) + event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur > 0) { /* Scroll up button: */ @@ -18541,9 +17770,7 @@ static int do_open(void) (button_h * buttons_tall + r_ttools.h - img_scroll_up->h) && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 - && event.button.x <= - (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur < num_files - 16) + && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur < num_files - 16) { /* Scroll down button: */ @@ -18557,9 +17784,7 @@ static int do_open(void) && event.button.x < (WINDOW_WIDTH - r_ttoolopt.w)) || (event.button.x >= (WINDOW_WIDTH - r_ttoolopt.w - button_w - button_w - - button_w) - && event.button.x < - (WINDOW_WIDTH - button_w - r_ttoolopt.w) && + button_w) && event.button.x < (WINDOW_WIDTH - button_w - r_ttoolopt.w) && /* Both "Erase" and "Export" only work on our own files... */ d_places[which] != PLACE_STARTERS_DIR && d_places[which] != PLACE_PERSONAL_STARTERS_DIR)) && @@ -18578,9 +17803,7 @@ static int do_open(void) (button_h * buttons_tall + r_ttools.h) - button_h && ((((event.button.x - r_ttools.w) / (THUMB_W) + - (((event.button.y - - img_scroll_up->h) / THUMB_H) * 4)) + cur) < - num_files)) + (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur) < num_files)) { /* One of the thumbnails: */ @@ -18622,20 +17845,17 @@ static int do_open(void) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, - &valhat_y, &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } /* while (SDL_PollEvent(&event)) */ if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); @@ -18649,12 +17869,9 @@ static int do_open(void) thumbs[which], img_popup_arrow, img_trash, SND_AREYOUSURE, WINDOW_WIDTH - r_ttoolopt.w - button_w - - button_w + 24, - button_h * buttons_tall + r_ttools.h - - button_h + img_scroll_up->h)) + button_w + 24, button_h * buttons_tall + r_ttools.h - button_h + img_scroll_up->h)) { - safe_snprintf(fname, sizeof(fname), "saved/%s%s", d_names[which], - d_exts[which]); + safe_snprintf(fname, sizeof(fname), "saved/%s%s", d_names[which], d_exts[which]); rfname = get_fname(fname, DIR_SAVE); @@ -18665,8 +17882,7 @@ static int do_open(void) /* Delete the thumbnail, too: */ - safe_snprintf(fname, sizeof(fname), "saved/.thumbs/%s-t.png", - d_names[which]); + safe_snprintf(fname, sizeof(fname), "saved/.thumbs/%s-t.png", d_names[which]); free(rfname); rfname = get_fname(fname, DIR_SAVE); @@ -18676,8 +17892,7 @@ static int do_open(void) /* Try deleting old-style thumbnail, too: */ - safe_snprintf(fname, sizeof(fname), "saved/%s-t.png", - d_names[which]); + safe_snprintf(fname, sizeof(fname), "saved/%s-t.png", d_names[which]); free(rfname); rfname = get_fname(fname, DIR_SAVE); @@ -18687,8 +17902,7 @@ static int do_open(void) /* Delete .dat file, if any: */ - safe_snprintf(fname, sizeof(fname), "saved/%s.dat", - d_names[which]); + safe_snprintf(fname, sizeof(fname), "saved/%s.dat", d_names[which]); free(rfname); rfname = get_fname(fname, DIR_SAVE); @@ -18736,8 +17950,7 @@ static int do_open(void) if (which < 0) { do_prompt_snd(PROMPT_OPEN_NOFILES_TXT, - PROMPT_OPEN_NOFILES_YES, "", SND_YOUCANNOT, - screen->w / 2, screen->h / 2); + PROMPT_OPEN_NOFILES_YES, "", SND_YOUCANNOT, screen->w / 2, screen->h / 2); done = 1; } } @@ -18761,12 +17974,10 @@ static int do_open(void) { want_export = 0; - safe_snprintf(fname, sizeof(fname), "saved/%s%s", d_names[which], - d_exts[which]); + safe_snprintf(fname, sizeof(fname), "saved/%s%s", d_names[which], d_exts[which]); rfname = get_fname(fname, DIR_SAVE); if (export_pict(rfname)) - do_prompt_snd(PROMPT_PICT_EXPORT_TXT, PROMPT_EXPORT_YES, "", - SND_TUXOK, screen->w / 2, screen->h / 2); + do_prompt_snd(PROMPT_PICT_EXPORT_TXT, PROMPT_EXPORT_YES, "", SND_TUXOK, screen->w / 2, screen->h / 2); else do_prompt_snd(PROMPT_PICT_EXPORT_FAILED_TXT, PROMPT_EXPORT_YES, "", SND_YOUCANNOT, screen->w / 2, screen->h / 2); @@ -18791,9 +18002,7 @@ static int do_open(void) if (do_prompt_image_snd(PROMPT_OPEN_SAVE_TXT, PROMPT_OPEN_SAVE_YES, PROMPT_OPEN_SAVE_NO, - img_tools[TOOL_SAVE], NULL, NULL, - SND_AREYOUSURE, screen->w / 2, - screen->h / 2)) + img_tools[TOOL_SAVE], NULL, NULL, SND_AREYOUSURE, screen->w / 2, screen->h / 2)) { do_save(TOOL_OPEN, 1, 0); } @@ -18802,33 +18011,28 @@ static int do_open(void) /* Clean the label stuff */ delete_label_list(&start_label_node); start_label_node = current_label_node = - first_label_node_in_redo_stack = highlighted_label_node = - label_node_to_edit = NULL; + first_label_node_in_redo_stack = highlighted_label_node = label_node_to_edit = NULL; have_to_rec_label_node = FALSE; /* Clean stale text */ if (texttool_len > 0) - { - texttool_str[0] = L'\0'; - texttool_len = 0; - cursor_textwidth = 0; - } + { + texttool_str[0] = L'\0'; + texttool_len = 0; + cursor_textwidth = 0; + } SDL_FillRect(label, NULL, SDL_MapRGBA(label->format, 0, 0, 0, 0)); /* Figure out filename: */ - safe_snprintf(fname, sizeof(fname), "%s/%s%s", - dirname[d_places[which]], d_names[which], - d_exts[which]); + safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname[d_places[which]], d_names[which], d_exts[which]); fi = fopen(fname, "r"); if (fi == NULL) { fprintf(stderr, - "\nWarning: Couldn't load the saved image! (1)\n" - "%s\n" "The file is missing.\n\n\n", fname); - do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, - "", 0, 0); + "\nWarning: Couldn't load the saved image! (1)\n" "%s\n" "The file is missing.\n\n\n", fname); + do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", 0, 0); } fclose(fi); @@ -18839,11 +18043,9 @@ static int do_open(void) fprintf(stderr, "\nWarning: Couldn't load the saved image! (2)\n" "%s\n" - "The Simple DirectMedia Layer error that occurred " - "was:\n" "%s\n\n", fname, SDL_GetError()); + "The Simple DirectMedia Layer error that occurred " "was:\n" "%s\n\n", fname, SDL_GetError()); - do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, - "", 0, 0); + do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", 0, 0); } else { @@ -18907,8 +18109,7 @@ static int do_open(void) } - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w - r_ttools.w, - button_h * buttons_tall + r_ttools.h); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w - r_ttools.w, button_h * buttons_tall + r_ttools.h); free(instructions); } @@ -18966,8 +18167,7 @@ static int do_slideshow(void) int num_selected; FILE *fi; char fname[1024]; - int num_files, num_files_in_dir, i, done, update_list, cur, which, j, - go_back, found, speed; + int num_files, num_files_in_dir, i, done, update_list, cur, which, j, go_back, found, speed; SDL_Rect dest; SDL_Event event; SDLKey key; @@ -18988,7 +18188,7 @@ static int do_slideshow(void) things_alloced = 32; - fs = (struct dirent2 *) malloc(sizeof(struct dirent2) * things_alloced); + fs = (struct dirent2 *)malloc(sizeof(struct dirent2) * things_alloced); num_files_in_dir = 0; num_files = 0; @@ -19023,10 +18223,7 @@ static int do_slideshow(void) if (num_files_in_dir >= things_alloced) { things_alloced = things_alloced + 32; - fs = - (struct dirent2 *) realloc(fs, - sizeof(struct dirent2) * - things_alloced); + fs = (struct dirent2 *)realloc(fs, sizeof(struct dirent2) * things_alloced); } } } @@ -19039,19 +18236,17 @@ static int do_slideshow(void) /* (Re)allocate space for the information about these files: */ thumbs = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * num_files_in_dir); - d_names = (char **) malloc(sizeof(char *) * num_files_in_dir); - d_exts = (char **) malloc(sizeof(char *) * num_files_in_dir); - selected = (int *) malloc(sizeof(int) * num_files_in_dir); + d_names = (char **)malloc(sizeof(char *) * num_files_in_dir); + d_exts = (char **)malloc(sizeof(char *) * num_files_in_dir); + selected = (int *)malloc(sizeof(int) * num_files_in_dir); /* Sort: */ if (!reversesort) - qsort(fs, num_files_in_dir, sizeof(struct dirent2), - (int (*)(const void *, const void *)) compare_dirent2s); + qsort(fs, num_files_in_dir, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s); else - qsort(fs, num_files_in_dir, sizeof(struct dirent2), - (int (*)(const void *, const void *)) compare_dirent2s_invert); + qsort(fs, num_files_in_dir, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s_invert); /* Read directory of images and build thumbnails: */ @@ -19066,8 +18261,7 @@ static int do_slideshow(void) { debug(f->d_name); - if (strcasestr(f->d_name, "-t.") == NULL - && strcasestr(f->d_name, "-back.") == NULL) + if (strcasestr(f->d_name, "-t.") == NULL && strcasestr(f->d_name, "-back.") == NULL) { if (strcasestr(f->d_name, FNAME_EXTENSION) != NULL /* Support legacy BMP files for load: */ @@ -19077,13 +18271,13 @@ static int do_slideshow(void) if (strcasestr(fname, FNAME_EXTENSION) != NULL) { d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION)); - strcpy((char *) strcasestr(fname, FNAME_EXTENSION), ""); /* FIXME: Use strncpy() (ugh, complicated) */ + strcpy((char *)strcasestr(fname, FNAME_EXTENSION), ""); /* FIXME: Use strncpy() (ugh, complicated) */ } if (strcasestr(fname, ".bmp") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".bmp")); - strcpy((char *) strcasestr(fname, ".bmp"), ""); /* Safe; truncating */ + strcpy((char *)strcasestr(fname, ".bmp"), ""); /* Safe; truncating */ } d_names[num_files] = strdup(fname); @@ -19094,8 +18288,7 @@ static int do_slideshow(void) /* Try to load thumbnail first: */ - safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", dirname, - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", dirname, d_names[num_files]); debug("Loading thumbnail..."); debug(fname); img = IMG_Load(fname); @@ -19104,8 +18297,7 @@ static int do_slideshow(void) /* No thumbnail in the new location ("saved/.thumbs"), try the old locatin ("saved/"): */ - safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", dirname, - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", dirname, d_names[num_files]); debug(fname); img = IMG_Load(fname); @@ -19138,9 +18330,7 @@ static int do_slideshow(void) if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of saved image!\n" - "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of saved image!\n" "%s\n", fname); } else num_files++; @@ -19151,9 +18341,7 @@ static int do_slideshow(void) /* No thumbnail - load original: */ /* Make sure we have a ~/.tuxpaint/saved directory: */ - if (make_directory - (DIR_SAVE, "saved", - "Can't create user data directory (for saved drawings) (E008)")) + if (make_directory(DIR_SAVE, "saved", "Can't create user data directory (for saved drawings) (E008)")) { /* (Make sure we have a .../saved/.thumbs/ directory:) */ make_directory(DIR_SAVE, "saved/.thumbs", @@ -19175,8 +18363,7 @@ static int do_slideshow(void) fprintf(stderr, "\nWarning: I can't open one of the saved files!\n" "%s\n" - "The Simple DirectMedia Layer error that " - "occurred was:\n" "%s\n\n", fname, SDL_GetError()); + "The Simple DirectMedia Layer error that " "occurred was:\n" "%s\n\n", fname, SDL_GetError()); } else { @@ -19195,9 +18382,7 @@ static int do_slideshow(void) if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of saved image!\n" - "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of saved image!\n" "%s\n", fname); } else { @@ -19208,16 +18393,14 @@ static int do_slideshow(void) debug("Saving thumbnail for this one!"); - safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", - dirname, d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", dirname, d_names[num_files]); fi = fopen(fname, "wb"); if (fi == NULL) { fprintf(stderr, "\nError: Couldn't save thumbnail of saved image!\n" - "%s\n" "The error that occurred was:\n" "%s\n\n", - fname, strerror(errno)); + "%s\n" "The error that occurred was:\n" "%s\n\n", fname, strerror(errno)); } else { @@ -19308,14 +18491,8 @@ static int do_slideshow(void) if (thumbs[i] != NULL) { - dest.x = - THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - - thumbs[i]->w) / 2; - dest.y = - THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - - 20 - - thumbs[i]->h) - / 2; + dest.x = THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - thumbs[i]->w) / 2; + dest.y = THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - 20 - thumbs[i]->h) / 2; SDL_BlitSurface(thumbs[i], NULL, screen, &dest); } @@ -19330,12 +18507,9 @@ static int do_slideshow(void) if (found != -1) { - dest.x = - (THUMB_W * ((i - cur) % 4) + r_ttools.h + 10 + - (THUMB_W - 20 - thumbs[i]->w) / 2) + thumbs[i]->w; + dest.x = (THUMB_W * ((i - cur) % 4) + r_ttools.h + 10 + (THUMB_W - 20 - thumbs[i]->w) / 2) + thumbs[i]->w; dest.y = - (THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + - (THUMB_H - 20 - thumbs[i]->h) / 2) + thumbs[i]->h; + (THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - 20 - thumbs[i]->h) / 2) + thumbs[i]->h; draw_selection_digits(dest.x, dest.y, found + 1); } @@ -19368,8 +18542,7 @@ static int do_slideshow(void) SDL_BlitSurface(img_play, NULL, screen, &dest); dest.x = r_ttools.w + (button_w - img_openlabels_play->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_play->h; // FIXME: CROP LABELS + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_play->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_play, NULL, screen, &dest); @@ -19379,18 +18552,12 @@ static int do_slideshow(void) dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_btn_up, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w * 2 + (button_w - - img_gif_export->w) / 2; + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w * 2 + (button_w - img_gif_export->w) / 2; dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_gif_export, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w * 2 + (button_w - - img_openlabels_gif_export-> - w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_gif_export->h; // FIXME: CROP LABELS + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w * 2 + (button_w - img_openlabels_gif_export->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_gif_export->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_gif_export, NULL, screen, &dest); @@ -19400,19 +18567,16 @@ static int do_slideshow(void) dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_back, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - - img_openlabels_back->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - img_openlabels_back->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_back, NULL, screen, &dest); /* Speed control: */ speeds = 10; - x_per = (float) r_ttools.w / speeds; - y_per = (float) button_h / speeds; + x_per = (float)r_ttools.w / speeds; + y_per = (float)button_h / speeds; for (i = 0; i < speeds; i++) { @@ -19485,8 +18649,7 @@ static int do_slideshow(void) // playsound(screen, 1, SND_CLICK, 1, SNDPOS_LEFT, SNDDIST_NEAR); event.type = SDL_MOUSEBUTTONDOWN; event.button.x = button_w * 2 + 5; - event.button.y = - (button_h * buttons_tall + r_ttools.h) - button_h + 5; + event.button.y = (button_h * buttons_tall + r_ttools.h) - button_h + 5; event.button.button = 1; SDL_PushEvent(&event); @@ -19503,20 +18666,16 @@ static int do_slideshow(void) } else if ((event.type == SDL_MOUSEBUTTONDOWN - && valid_click(event.button.button)) - || event.type == TP_SDL_MOUSEBUTTONSCROLL) + && valid_click(event.button.button)) || event.type == TP_SDL_MOUSEBUTTONSCROLL) { if (event.button.x >= r_ttools.w && event.button.x < WINDOW_WIDTH - r_ttoolopt.w - && event.button.y >= img_scroll_up->h - && event.button.y < - (button_h * buttons_tall + r_ttools.h - button_h)) + && event.button.y >= img_scroll_up->h && event.button.y < (button_h * buttons_tall + r_ttools.h - button_h)) { /* Picked an icon! */ which = - ((event.button.x - r_ttools.w) / (THUMB_W) + - (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur; + ((event.button.x - r_ttools.w) / (THUMB_W) + (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur; if (which < num_files) { @@ -19556,8 +18715,7 @@ static int do_slideshow(void) if (event.button.y < img_scroll_up->h || (event.button.y >= (button_h * buttons_tall + r_ttools.h - button_h) - && event.button.y < - (button_h * buttons_tall + r_ttools.h - img_scroll_down->h))) + && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_down->h))) { /* Up or Down scroll button in Slideshow dialog: */ @@ -19569,8 +18727,7 @@ static int do_slideshow(void) { cur = cur - 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur == 0) do_setcursor(cursor_arrow); @@ -19581,9 +18738,7 @@ static int do_slideshow(void) } else if (event.button.y >= (button_h * buttons_tall + r_ttools.h - button_h) - && event.button.y < - (button_h * buttons_tall + r_ttools.h - - img_scroll_down->h)) + && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_down->h)) { /* Down scroll button: */ @@ -19591,8 +18746,7 @@ static int do_slideshow(void) { cur = cur + 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur >= num_files - 16) do_setcursor(cursor_arrow); @@ -19617,15 +18771,13 @@ static int do_slideshow(void) scrolling_dialog = 1; scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } else { DEBUG_PRINTF("Continuing scrolling\n"); scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } } else if (event.button.x >= r_ttools.w @@ -19648,14 +18800,12 @@ static int do_slideshow(void) num_selected = num_files; } - play_slideshow(selected, num_selected, dirname, d_names, d_exts, - speed); + play_slideshow(selected, num_selected, dirname, d_names, d_exts, speed); /* Redraw entire screen, after playback: */ - SDL_FillRect(screen, NULL, - SDL_MapRGB(canvas->format, 255, 255, 255)); + SDL_FillRect(screen, NULL, SDL_MapRGB(canvas->format, 255, 255, 255)); draw_toolbar(); draw_colors(COLORSEL_CLOBBER_WIPE); draw_none(); @@ -19693,8 +18843,7 @@ static int do_slideshow(void) if (control_sound != -1) { - playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 0, control_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); update_list = 1; } @@ -19715,9 +18864,7 @@ static int do_slideshow(void) /* None selected? Too dangerous to automatically select all (like we do for slideshow playback). Only 1 selected? No point in saving as GIF. */ - freeme = - textdir(gettext_noop - ("Select 2 or more drawings to turn into an animated GIF.")); + freeme = textdir(gettext_noop("Select 2 or more drawings to turn into an animated GIF.")); draw_tux_text(TUX_BORED, freeme, 1); free(freeme); @@ -19725,21 +18872,17 @@ static int do_slideshow(void) } else { - export_successful = - export_gif(selected, num_selected, dirname, d_names, d_exts, - speed); + export_successful = export_gif(selected, num_selected, dirname, d_names, d_exts, speed); /* Redraw entire screen, after export: */ - SDL_FillRect(screen, NULL, - SDL_MapRGB(canvas->format, 255, 255, 255)); + SDL_FillRect(screen, NULL, SDL_MapRGB(canvas->format, 255, 255, 255)); draw_toolbar(); draw_colors(COLORSEL_CLOBBER_WIPE); draw_none(); /* Show a message depending on success */ if (export_successful) - do_prompt_snd(PROMPT_GIF_EXPORT_TXT, PROMPT_EXPORT_YES, "", - SND_TUXOK, screen->w / 2, screen->h / 2); + do_prompt_snd(PROMPT_GIF_EXPORT_TXT, PROMPT_EXPORT_YES, "", SND_TUXOK, screen->w / 2, screen->h / 2); else do_prompt_snd(PROMPT_GIF_EXPORT_FAILED_TXT, PROMPT_EXPORT_YES, "", SND_YOUCANNOT, screen->w / 2, screen->h / 2); @@ -19804,8 +18947,7 @@ static int do_slideshow(void) if (event.button.y < img_scroll_up->h && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 && - event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur > 0) + event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur > 0) { /* Scroll up button: */ @@ -19816,8 +18958,7 @@ static int do_slideshow(void) && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_up->h) && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 - && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur < num_files - 16) + && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur < num_files - 16) { /* Scroll down button: */ @@ -19844,8 +18985,7 @@ static int do_slideshow(void) (button_h * buttons_tall + r_ttools.h) - button_h && ((((event.button.x - r_ttools.w) / (THUMB_W) + - (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + - cur) < num_files)) + (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur) < num_files)) { /* One of the thumbnails: */ @@ -19888,14 +19028,12 @@ static int do_slideshow(void) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); else if (event.type == SDL_USEREVENT) @@ -19911,8 +19049,7 @@ static int do_slideshow(void) } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -19956,8 +19093,7 @@ static int do_slideshow(void) * @char ** d_ext -- array of file exentions of the images to be played * @int speed -- how fast to play the slideshow (0 = no automatic advance, 1 = slowest, 10 = as fast as possible) */ -static void play_slideshow(int *selected, int num_selected, char *dirname, - char **d_names, char **d_exts, int speed) +static void play_slideshow(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed) { int i, which, next, done; int val_x, val_y, motioner; @@ -19966,6 +19102,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, SDL_Surface *img; char *tmp_starter_id, *tmp_template_id, *tmp_file_id; int tmp_starter_mirrored, tmp_starter_flipped, tmp_starter_personal; + /* FIXME: Do we want to keep `template_personal` safe, too? */ char fname[1024]; SDL_Event event; @@ -20000,8 +19137,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, /* Figure out filename: */ - safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname, d_names[which], - d_exts[which]); + safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname, d_names[which], d_exts[which]); img = myIMG_Load(fname); @@ -20043,7 +19179,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, SDL_BlitSurface(img_back, NULL, screen, &dest); dest.x = screen->w - button_w + (button_w - img_openlabels_back->w) / 2; - dest.y = screen->h - img_openlabels_back->h; // FIXME: CROP LABELS + dest.y = screen->h - img_openlabels_back->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_back, NULL, screen, &dest); /* "Next" button: */ @@ -20053,7 +19189,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, SDL_BlitSurface(img_play, NULL, screen, &dest); dest.x = (button_w - img_openlabels_next->w) / 2; - dest.y = screen->h - img_openlabels_next->h; // FIXME: CROP LABELS + dest.y = screen->h - img_openlabels_next->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_next, NULL, screen, &dest); @@ -20086,8 +19222,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, handle_keymouse(key, SDL_KEYDOWN, 24, NULL, NULL); - if (key == SDLK_RETURN || key == SDLK_SPACE - || key == SDLK_PAGEDOWN) + if (key == SDLK_RETURN || key == SDLK_SPACE || key == SDLK_PAGEDOWN) { /* RETURN, SPACE or PAGEDOWN: Skip to next right away! */ @@ -20119,8 +19254,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, { /* Mouse click! */ - if (event.button.x >= screen->w - button_w - && event.button.y >= screen->h - button_h) + if (event.button.x >= screen->w - button_w && event.button.y >= screen->h - button_h) { /* Back button */ @@ -20141,8 +19275,7 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, /* Deal with mouse pointer shape! */ if ((event.button.x >= screen->w - button_w - || event.button.x < button_w) - && event.button.y >= screen->h - button_h) + || event.button.x < button_w) && event.button.y >= screen->h - button_h) { /* Back or Next buttons */ @@ -20162,21 +19295,18 @@ static void play_slideshow(int *selected, int num_selected, char *dirname, handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, - &valhat_y, &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); @@ -20289,17 +19419,8 @@ static void wait_for_sfx(void) #define STIPLE_W 10 #define STIPLE_H 10 static char stiple[] = -"8844221100" -"8844221100" -"1100884422" -"1100884422" -"4422110088" -"4422110088" -"0088442211" -"0088442211" -"2211008844" -"2211008844" -; + "8844221100" + "8844221100" "1100884422" "1100884422" "4422110088" "4422110088" "0088442211" "0088442211" "2211008844" "2211008844"; #endif #if 1 @@ -20323,29 +19444,25 @@ static char stiple[] = "008088080000" "808000000808" "000080880800" - "088080000008" "000000808808" "080880800000" "080000008088" "000808808000" - "880800000080" "000008088080"; + "088080000008" "000000808808" "080880800000" "080000008088" "000808808000" "880800000080" "000008088080"; #endif static unsigned char *stamp_outline_data; static int stamp_outline_w, stamp_outline_h; -static void reset_stamps(int *stamp_xored_rt, int *stamp_place_x, - int *stamp_place_y, int *stamp_tool_mode) +static void reset_stamps(int *stamp_xored_rt, int *stamp_place_x, int *stamp_place_y, int *stamp_tool_mode) { if (!active_stamp) return; *stamp_xored_rt = 0; *stamp_tool_mode = STAMP_TOOL_MODE_PLACE; - int half_bigbox = - sqrt((CUR_STAMP_W + 1) * (CUR_STAMP_W + 1) + - (CUR_STAMP_H + 1) * (CUR_STAMP_H + 1)) / 2; + int half_bigbox = sqrt((CUR_STAMP_W + 1) * (CUR_STAMP_W + 1) + (CUR_STAMP_H + 1) * (CUR_STAMP_H + 1)) / 2; + update_screen(*stamp_place_x - half_bigbox + r_canvas.x, *stamp_place_y - half_bigbox + r_canvas.y, - *stamp_place_x + half_bigbox + r_canvas.x, - *stamp_place_y + half_bigbox + r_canvas.y); + *stamp_place_x + half_bigbox + r_canvas.x, *stamp_place_y + half_bigbox + r_canvas.y); update_stamp_xor(0); } @@ -20373,6 +19490,7 @@ static void update_stamp_xor(int stamp_angle_rotation) if (stamp_angle_rotation) { SDL_Surface *aux_surf = src; + src = rotozoomSurface(aux_surf, stamp_angle_rotation, 1.0, SMOOTHING_ON); SDL_FreeSurface(aux_surf); } @@ -20388,8 +19506,7 @@ static void update_stamp_xor(int stamp_angle_rotation) { rx = xx; SDL_GetRGBA(getpixel(src, rx, ry), - src->format, &dummy, &dummy, &dummy, - alphabits + xx + 2 + (yy + 2) * (src->w + 4)); + src->format, &dummy, &dummy, &dummy, alphabits + xx + 2 + (yy + 2) * (src->w + 4)); } } SDL_UnlockSurface(src); @@ -20471,18 +19588,24 @@ static void stamp_xor(int x, int y) xorpixel(sx, sy); - if (xx < stamp_outline_w - 1) { - if (stiple[(sx + 1) % STIPLE_W + sy % STIPLE_H * STIPLE_W] != '8') { + if (xx < stamp_outline_w - 1) + { + if (stiple[(sx + 1) % STIPLE_W + sy % STIPLE_H * STIPLE_W] != '8') + { xorpixel(sx + 1, sy); } } - if (yy < stamp_outline_h - 1) { - if (stiple[sx % STIPLE_W + (sy + 1) % STIPLE_H * STIPLE_W] != '8') { + if (yy < stamp_outline_h - 1) + { + if (stiple[sx % STIPLE_W + (sy + 1) % STIPLE_H * STIPLE_W] != '8') + { xorpixel(sx, sy + 1); } - if (xx < stamp_outline_w - 1) { - if (stiple[(sx + 1) % STIPLE_W + (sy + 1) % STIPLE_H * STIPLE_W] != '8') { + if (xx < stamp_outline_w - 1) + { + if (stiple[(sx + 1) % STIPLE_W + (sy + 1) % STIPLE_H * STIPLE_W] != '8') + { xorpixel(sx + 1, sy + 1); } } @@ -20497,8 +19620,7 @@ static void stamp_xor(int x, int y) /** * FIXME */ -static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, - float *v) +static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, float *v) { float rgb_min, rgb_max, delta, r, g, b; @@ -20541,8 +19663,7 @@ static void rgbtohsv(Uint8 r8, Uint8 g8, Uint8 b8, float *h, float *s, /** * FIXME */ -static void hsvtorgb(float h, float s, float v, Uint8 * r8, Uint8 * g8, - Uint8 * b8) +static void hsvtorgb(float h, float s, float v, Uint8 * r8, Uint8 * g8, Uint8 * b8) { int i; float f, p, q, t, r, g, b; @@ -20616,8 +19737,7 @@ static void print_image(void) int cur_time, scroll; cur_time = SDL_GetTicks() / 1000; - scroll = - (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; + scroll = (NUM_TOOLS > buttons_tall * gd_tools.cols) ? img_scroll_down->h : 0; DEBUG_PRINTF("Current time = %d\n", cur_time); @@ -20636,8 +19756,7 @@ static void print_image(void) img_printer, NULL, NULL, SND_AREYOUSURE, (TOOL_PRINT % 2) * button_w + button_w / 2, (TOOL_PRINT / 2) * button_h + r_ttools.h + - button_h / 2 - - tool_scroll * button_h / gd_tools.cols + scroll)) + button_h / 2 - tool_scroll * button_h / gd_tools.cols + scroll)) { do_print(); @@ -20647,8 +19766,7 @@ static void print_image(void) else { do_prompt_image_snd(PROMPT_PRINT_TOO_SOON_TXT, - PROMPT_PRINT_TOO_SOON_YES, "", img_printer_wait, NULL, - NULL, SND_YOUCANNOT, 0, screen->h); + PROMPT_PRINT_TOO_SOON_YES, "", img_printer_wait, NULL, NULL, SND_YOUCANNOT, 0, screen->h); } } @@ -20682,17 +19800,14 @@ void do_print(void) { #ifdef PRINTMETHOD_PNG_PNM_PS if (do_png_save(pi, pcmd, save_canvas, 0)) - do_prompt_snd(PROMPT_PRINT_TXT, PROMPT_PRINT_YES, "", SND_TUXOK, - screen->w / 2, screen->h / 2); + do_prompt_snd(PROMPT_PRINT_TXT, PROMPT_PRINT_YES, "", SND_TUXOK, screen->w / 2, screen->h / 2); #elif defined(PRINTMETHOD_PNM_PS) /* nothing here */ #elif defined(PRINTMETHOD_PS) if (do_ps_save(pi, pcmd, save_canvas, papersize, 1)) - do_prompt_snd(PROMPT_PRINT_TXT, PROMPT_PRINT_YES, "", SND_TUXOK, - screen->w / 2, screen->h / 2); + do_prompt_snd(PROMPT_PRINT_TXT, PROMPT_PRINT_YES, "", SND_TUXOK, screen->w / 2, screen->h / 2); else - do_prompt_snd(PROMPT_PRINT_FAILED_TXT, PROMPT_PRINT_YES, "", - SND_YOUCANNOT, screen->w / 2, screen->h / 2); + do_prompt_snd(PROMPT_PRINT_FAILED_TXT, PROMPT_PRINT_YES, "", SND_YOUCANNOT, screen->w / 2, screen->h / 2); #else #error No print method defined! #endif @@ -20707,9 +19822,8 @@ void do_print(void) safe_snprintf(f, sizeof(f), "%s/%s", savedir, "print.cfg"); /* FIXME */ { - const char *error = - SurfacePrint(window_screen, save_canvas, use_print_config ? f : NULL, - show); + const char *error = SurfacePrint(window_screen, save_canvas, use_print_config ? f : NULL, + show); if (error) fprintf(stderr, "%s\n", error); @@ -20736,10 +19850,8 @@ void do_print(void) Uint8 src_r, src_g, src_b, src_a; SDL_Surface *save_canvas_and = SDL_CreateRGBSurface(0, WINDOW_WIDTH - (96 * 2), - (48 * 7) + 40 + - HEIGHTOFFSET, - screen->format-> - BitsPerPixel, + (48 * 7) + 40 + HEIGHTOFFSET, + screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, @@ -20750,16 +19862,13 @@ void do_print(void) for (y = 0; y < save_canvas->h; y++) { SDL_GetRGBA(getpixels[save_canvas->format->BytesPerPixel] - (save_canvas, x, y), save_canvas->format, &src_r, &src_g, - &src_b, &src_a); + (save_canvas, x, y), save_canvas->format, &src_r, &src_g, &src_b, &src_a); putpixels[save_canvas_and->format->BytesPerPixel] (save_canvas_and, x, y, SDL_MapRGBA - (save_canvas_and-> - format, src_r, - src_g, src_b, - SDL_ALPHA_OPAQUE)); + (save_canvas_and->format, src_r, + src_g, src_b, SDL_ALPHA_OPAQUE)); } const char *error = SurfacePrint(save_canvas_and); @@ -20799,13 +19908,9 @@ static void do_render_cur_text(int do_blit) /* Keep cursor on the screen! */ - if (cursor_y > - ((button_h * buttons_tall + r_ttools.h) - - TuxPaint_Font_FontHeight(getfonthandle(cur_font)))) + if (cursor_y > ((button_h * buttons_tall + r_ttools.h) - TuxPaint_Font_FontHeight(getfonthandle(cur_font)))) { - cursor_y = - ((button_h * buttons_tall + r_ttools.h) - - TuxPaint_Font_FontHeight(getfonthandle(cur_font))); + cursor_y = ((button_h * buttons_tall + r_ttools.h) - TuxPaint_Font_FontHeight(getfonthandle(cur_font))); } @@ -20823,24 +19928,23 @@ static void do_render_cur_text(int do_blit) FriBidiChar *unicodeIn, *unicodeOut; unsigned int i; - unicodeIn = - (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1)); - unicodeOut = - (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1)); + unicodeIn = (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1)); + unicodeOut = (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1)); - str = (wchar_t *) malloc(sizeof(wchar_t) * (texttool_len + 1)); + str = (wchar_t *)malloc(sizeof(wchar_t) * (texttool_len + 1)); for (i = 0; i < texttool_len; i++) unicodeIn[i] = (FriBidiChar) texttool_str[i]; int maxlevel = fribidi_log2vis(unicodeIn, texttool_len, &baseDir, unicodeOut, 0, 0, 0); - maxlevel = maxlevel; // FIXME: Avoiding "unused variable" warning. Note: if we remove it, baseDir isn't used either! -bjk 2023.02.12 + + maxlevel = maxlevel; // FIXME: Avoiding "unused variable" warning. Note: if we remove it, baseDir isn't used either! -bjk 2023.02.12 /* FIXME: If we determine that some new text was RtoL, we should reposition the text */ for (i = 0; i < texttool_len; i++) - str[i] = (long) unicodeOut[i]; + str[i] = (long)unicodeOut[i]; str[texttool_len] = L'\0'; @@ -20854,8 +19958,8 @@ static void do_render_cur_text(int do_blit) w = tmp_surf->w; h = tmp_surf->h; - r_tir.h = (float) tmp_surf->h / render_scale; - r_tir.w = (float) tmp_surf->w / render_scale; + r_tir.h = (float)tmp_surf->h / render_scale; + r_tir.w = (float)tmp_surf->w / render_scale; cursor_textwidth = w; } @@ -20863,17 +19967,13 @@ static void do_render_cur_text(int do_blit) { if (cur_label != LABEL_SELECT && cur_label != LABEL_APPLY) { - update_canvas_ex_r(old_dest.x - r_ttools.w, old_dest.y, - old_dest.x + old_dest.w, old_dest.y + old_dest.h, 0); + update_canvas_ex_r(old_dest.x - r_ttools.w, old_dest.y, old_dest.x + old_dest.w, old_dest.y + old_dest.h, 0); old_dest.x = old_dest.y = old_dest.w = old_dest.h = 0; update_canvas_ex_r(old_cursor_x - 1, old_cursor_y - 1, - old_cursor_x + 1, - old_cursor_y + 1 + - TuxPaint_Font_FontHeight(getfonthandle(cur_font)), - 0); + old_cursor_x + 1, old_cursor_y + 1 + TuxPaint_Font_FontHeight(getfonthandle(cur_font)), 0); /* FIXME: Do less flickery updating here (use update_canvas_ex() above, then SDL_Flip() or SDL_UpdateRect() here -bjk 2010.02.10 */ @@ -20890,8 +19990,7 @@ static void do_render_cur_text(int do_blit) if (!do_blit) { - update_canvas_ex_r(old_dest.x - r_ttools.w, old_dest.y, - old_dest.x + old_dest.w, old_dest.y + old_dest.h, 0); + update_canvas_ex_r(old_dest.x - r_ttools.w, old_dest.y, old_dest.x + old_dest.w, old_dest.y + old_dest.h, 0); /* update_canvas_ex_r(cursor_x - 1, */ /* cursor_y - 1, */ @@ -20930,8 +20029,7 @@ static void do_render_cur_text(int do_blit) if (dest.y + dest.h > (button_h * buttons_tall + r_ttools.h)) dest.h = (button_h * buttons_tall + r_ttools.h) - dest.y; - if ((color_hexes[cur_color][0] + color_hexes[cur_color][1] + - color_hexes[cur_color][2]) >= 384) + if ((color_hexes[cur_color][0] + color_hexes[cur_color][1] + color_hexes[cur_color][2]) >= 384) { /* Grey background if blit is white!... */ @@ -20968,8 +20066,7 @@ static void do_render_cur_text(int do_blit) if ((cur_tool == TOOL_LABEL && label_node_to_edit) || ((old_tool == TOOL_LABEL && label_node_to_edit) && (cur_tool == TOOL_PRINT || - cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN - || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) + cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) { have_to_rec_label_node = TRUE; add_label_node(src.w, src.h, dest.x, dest.y, tmp_surf); @@ -20978,8 +20075,7 @@ static void do_render_cur_text(int do_blit) else if (cur_tool == TOOL_LABEL || (old_tool == TOOL_LABEL && (cur_tool == TOOL_PRINT || - cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN - || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) + cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) { myblit(tmp_surf, &src, label, &dest); @@ -20991,8 +20087,7 @@ static void do_render_cur_text(int do_blit) { SDL_BlitSurface(tmp_surf, &src, canvas, &dest); } - update_canvas_ex_r(dest.x - 2, dest.y - 2, dest.x + tmp_surf->w + 4, - dest.y + tmp_surf->h + 4, 0); + update_canvas_ex_r(dest.x - 2, dest.y - 2, dest.x + tmp_surf->w + 4, dest.y + tmp_surf->h + 4, 0); } else { @@ -21097,10 +20192,10 @@ static char *textdir(const char *const str) { j = (strlen(str) - i - 1); - c1 = (unsigned char) str[i + 0]; - c2 = (unsigned char) str[i + 1]; - c3 = (unsigned char) str[i + 2]; - c4 = (unsigned char) str[i + 3]; + c1 = (unsigned char)str[i + 0]; + c2 = (unsigned char)str[i + 1]; + c3 = (unsigned char)str[i + 2]; + c4 = (unsigned char)str[i + 3]; if (c1 < 128) /* 0xxx xxxx - 1 byte */ { @@ -21131,12 +20226,12 @@ static char *textdir(const char *const str) } else { - strcpy((char *) dstr, str); /* safe; malloc'd to a sufficient size */ + strcpy((char *)dstr, str); /* safe; malloc'd to a sufficient size */ } DEBUG_PRINTF("L2R_DIR: %s\n", dstr); - return ((char *) dstr); + return ((char *)dstr); } @@ -21205,8 +20300,7 @@ static Uint32 scrolltimer_dialog_callback(Uint32 interval, void *param) * FIXME */ /* Controls the Text-Timer - interval == 0 removes the timer */ -static void control_drawtext_timer(Uint32 interval, const char *const text, - Uint8 locale_text) +static void control_drawtext_timer(Uint32 interval, const char *const text, Uint8 locale_text) { static int activated = 0; static SDL_TimerID TimerID = 0; @@ -21227,14 +20321,13 @@ static void control_drawtext_timer(Uint32 interval, const char *const text, drawtext_event.type = SDL_USEREVENT; drawtext_event.user.code = USEREVENT_TEXT_UPDATE; - drawtext_event.user.data1 = (void *) text; - drawtext_event.user.data2 = (void *) (intptr_t) ((int) locale_text); //EP added (intptr_t) to avoid warning on x64 + drawtext_event.user.data1 = (void *)text; + drawtext_event.user.data2 = (void *)(intptr_t) ((int)locale_text); //EP added (intptr_t) to avoid warning on x64 /* Add new timer */ - TimerID = - SDL_AddTimer(interval, drawtext_callback, (void *) &drawtext_event); + TimerID = SDL_AddTimer(interval, drawtext_callback, (void *)&drawtext_event); activated = 1; } @@ -21245,7 +20338,7 @@ static void control_drawtext_timer(Uint32 interval, const char *const text, /* Drawtext Timer */ static Uint32 drawtext_callback(Uint32 interval, void *param) { - (void) interval; + (void)interval; SDL_PushEvent((SDL_Event *) param); return 0; /* Remove timer */ @@ -21316,8 +20409,7 @@ static void draw_image_title(int t, SDL_Rect dest) /* Handle keyboard events to control the mouse: */ /* Move as many pixels as bigsteps outside the areas, in the areas and 5 pixels around, move 1 pixel at a time */ -static void handle_keymouse(SDLKey key, Uint32 updown, int steps, - SDL_Rect * area1, SDL_Rect * area2) +static void handle_keymouse(SDLKey key, Uint32 updown, int steps, SDL_Rect * area1, SDL_Rect * area2) { int left, right, up, bottom; SDL_Event event; @@ -21360,11 +20452,7 @@ static void handle_keymouse(SDLKey key, Uint32 updown, int steps, && oldpos_x > r2.x && oldpos_x - - r2.x < r2.w - && oldpos_y > - r2.y - && oldpos_y - - r2.y < r2.h)) + r2.x < r2.w && oldpos_y > r2.y && oldpos_y - r2.y < r2.h)) { left = max(0, oldpos_x - 1); right = min(screen->w, oldpos_x + 1); @@ -21450,8 +20538,7 @@ static void handle_keymouse(SDLKey key, Uint32 updown, int steps, else if (cur_tool != TOOL_TEXT && cur_tool != TOOL_LABEL) { - if (!button_down - && (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP_5)) + if (!button_down && (key == SDLK_SPACE || key == SDLK_5 || key == SDLK_KP_5)) { event.type = SDL_MOUSEBUTTONDOWN; event.button.x = oldpos_x; @@ -21509,15 +20596,12 @@ static void handle_keymouse(SDLKey key, Uint32 updown, int steps, * FIXME */ /* A subset of keys that will move one button at a time and jump between r_canvas<->r_tools<->r_colors */ -static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, - SDL_Rect real_r_tools) +static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, SDL_Rect real_r_tools) { if (hit_test(&real_r_tools, oldpos_x, oldpos_y) && - (key == SDLK_F7 || key == SDLK_F8 || key == SDLK_F11 - || key == SDLK_F12)) + (key == SDLK_F7 || key == SDLK_F8 || key == SDLK_F11 || key == SDLK_F12)) { - *whicht = - tool_scroll + grid_hit_gd(&real_r_tools, oldpos_x, oldpos_y, &gd_tools); + *whicht = tool_scroll + grid_hit_gd(&real_r_tools, oldpos_x, oldpos_y, &gd_tools); if (key == SDLK_F7 && hit_test(&real_r_tools, oldpos_x, oldpos_y)) { @@ -21556,9 +20640,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, else if (key == SDLK_F11 && hit_test(&real_r_tools, oldpos_x, oldpos_y)) { - *whicht = - tool_scroll + grid_hit_gd(&real_r_tools, oldpos_x, oldpos_y, - &gd_tools); + *whicht = tool_scroll + grid_hit_gd(&real_r_tools, oldpos_x, oldpos_y, &gd_tools); *whicht = *whicht - 1; if (*whicht < 0) *whicht += NUM_TOOLS; @@ -21594,8 +20676,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, *whichc = *whichc - 1; if (*whichc < 0) *whichc += NUM_COLORS; - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, - r_canvas.h + (r_colors.h / 2)); + SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); } else if (key == SDLK_F12 && hit_test(&r_colors, oldpos_x, oldpos_y)) @@ -21603,15 +20684,13 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, *whichc = grid_hit_gd(&r_colors, oldpos_x, oldpos_y, &gd_colors); *whichc = *whichc + 1; *whichc = *whichc % NUM_COLORS; - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, - r_canvas.h + (r_colors.h / 2)); + SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); } else if (key == SDLK_F4) { if (hit_test(&r_tools, oldpos_x, oldpos_y)) - SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, - r_canvas.h + (r_colors.h / 2)); + SDL_WarpMouse(button_w * 2 + *whichc * color_button_w + 12, r_canvas.h + (r_colors.h / 2)); else if (hit_test(&r_colors, oldpos_x, oldpos_y)) SDL_WarpMouse(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2); else @@ -21630,8 +20709,7 @@ static void handle_keymouse_buttons(SDLKey key, int *whicht, int *whichc, /* Unblank screen in fullscreen mode, if needed: */ static void handle_active(SDL_Event * event) { - if (event->window.event == SDL_WINDOWEVENT_EXPOSED - || SDL_WINDOWEVENT_RESTORED) + if (event->window.event == SDL_WINDOWEVENT_EXPOSED || SDL_WINDOWEVENT_RESTORED) { // if (fullscreen) SDL_Flip(screen); @@ -21660,8 +20738,7 @@ static void handle_active(SDL_Event * event) /* For right-to-left languages, when word-wrapping, we need to make sure the text doesn't end up going from bottom-to-top, too! */ #ifdef NO_SDLPANGO -static void anti_carriage_return(int left, int right, int cur_top, - int new_top, int cur_bot, int line_width) +static void anti_carriage_return(int left, int right, int cur_top, int new_top, int cur_bot, int line_width) { SDL_Rect src, dest; @@ -21956,8 +21033,8 @@ static SDL_Surface *load_svg(const char *file) scale = pick_best_scape(rwidth, rheight, r_canvas.w, r_canvas.h); - width = ((float) rwidth * scale); - height = ((float) rheight * scale); + width = ((float)rwidth * scale); + height = ((float)rheight * scale); DEBUG_PRINTF("scaling to %d x %d (%f scale)\n", width, height, scale); @@ -21973,9 +21050,7 @@ static SDL_Surface *load_svg(const char *file) /* Create the cairo surface with the adjusted width and height */ - cairo_surface = - cairo_image_surface_create_for_data(image, CAIRO_FORMAT_ARGB32, width, - height, stride); + cairo_surface = cairo_image_surface_create_for_data(image, CAIRO_FORMAT_ARGB32, width, height, stride); cr = cairo_create(cairo_surface); if (cr == NULL) { @@ -22010,9 +21085,7 @@ static SDL_Surface *load_svg(const char *file) amask = 0xff000000; /* Create the SDL surface using the pixel data stored: */ - sdl_surface_tmp = - SDL_CreateRGBSurfaceFrom((void *) image, width, height, bpp, stride, - rmask, gmask, bmask, amask); + sdl_surface_tmp = SDL_CreateRGBSurfaceFrom((void *)image, width, height, bpp, stride, rmask, gmask, bmask, amask); if (sdl_surface_tmp == NULL) { @@ -22031,8 +21104,7 @@ static SDL_Surface *load_svg(const char *file) return (NULL); } - DEBUG_PRINTF("SDL surface from %d x %d SVG is %d x %d\n", rwidth, rheight, - sdl_surface->w, sdl_surface->h); + DEBUG_PRINTF("SDL surface from %d x %d SVG is %d x %d\n", rwidth, rheight, sdl_surface->w, sdl_surface->h); return (sdl_surface); } @@ -22084,8 +21156,8 @@ static SDL_Surface *_load_svg(const char *file) DEBUG_PRINTF("best scale is %.4f\n", scale); - width = ((float) rwidth * scale); - height = ((float) rheight * scale); + width = ((float)rwidth * scale); + height = ((float)rheight * scale); DEBUG_PRINTF("scaling to %d x %d (%f scale)\n", width, height, scale); @@ -22104,9 +21176,7 @@ static SDL_Surface *_load_svg(const char *file) /* Create a surface for Cairo to draw into: */ - cairo_surf = - cairo_image_surface_create_for_data(image, CAIRO_FORMAT_ARGB32, width, - height, stride); + cairo_surf = cairo_image_surface_create_for_data(image, CAIRO_FORMAT_ARGB32, width, height, stride); if (cairo_surface_status(cairo_surf) != CAIRO_STATUS_SUCCESS) { @@ -22154,9 +21224,7 @@ static SDL_Surface *_load_svg(const char *file) amask = 0xff000000; /* Create the SDL surface using the pixel data stored: */ - sdl_surface_tmp = - SDL_CreateRGBSurfaceFrom((void *) image, width, height, bpp, stride, - rmask, gmask, bmask, amask); + sdl_surface_tmp = SDL_CreateRGBSurfaceFrom((void *)image, width, height, bpp, stride, rmask, gmask, bmask, amask); if (sdl_surface_tmp == NULL) { @@ -22205,6 +21273,7 @@ static SDL_Surface *_load_svg(const char *file) static SDL_Surface *load_svg(const char *file) { SDL_Surface *sdl_surface; + sdl_surface = _load_svg(file); if (sdl_surface == NULL) sdl_surface = IMG_Load(file); @@ -22217,17 +21286,16 @@ static SDL_Surface *load_svg(const char *file) /** * FIXME */ -static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, - unsigned int max_w, unsigned int max_h) +static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, unsigned int max_w, unsigned int max_h) { float aspect, scale, wscale, hscale; - aspect = (float) orig_w / (float) orig_h; + aspect = (float)orig_w / (float)orig_h; DEBUG_PRINTF("trying to fit %d x %d (aspect: %.4f) into %d x %d\n", orig_w, orig_h, aspect, max_w, max_h); - wscale = (float) max_w / (float) orig_w; - hscale = (float) max_h / (float) orig_h; + wscale = (float)max_w / (float)orig_w; + hscale = (float)max_h / (float)orig_h; DEBUG_PRINTF("max_w / orig_w = wscale: %.4f\n", wscale); DEBUG_PRINTF("max_h / orig_h = hscale: %.4f\n", hscale); @@ -22240,16 +21308,14 @@ static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, scale = wscale; DEBUG_PRINTF("Wider-than-tall. Using wscale.\n"); - DEBUG_PRINTF("new size would be: %d x %d\n", (int) ((float) orig_w * scale), - (int) ((float) orig_h * scale)); + DEBUG_PRINTF("new size would be: %d x %d\n", (int)((float)orig_w * scale), (int)((float)orig_h * scale)); - if ((float) orig_h * scale > (float) max_h) + if ((float)orig_h * scale > (float)max_h) { scale = hscale; DEBUG_PRINTF("Too tall! Using hscale!\n"); - DEBUG_PRINTF("new size would be: %d x %d\n", (int) ((float) orig_w * scale), - (int) ((float) orig_h * scale)); + DEBUG_PRINTF("new size would be: %d x %d\n", (int)((float)orig_w * scale), (int)((float)orig_h * scale)); } } else @@ -22259,16 +21325,14 @@ static float pick_best_scape(unsigned int orig_w, unsigned int orig_h, scale = hscale; DEBUG_PRINTF("Taller-than-wide. Using hscale.\n"); - DEBUG_PRINTF("new size would be: %d x %d\n", (int) ((float) orig_w * scale), - (int) ((float) orig_h * scale)); + DEBUG_PRINTF("new size would be: %d x %d\n", (int)((float)orig_w * scale), (int)((float)orig_h * scale)); - if ((float) orig_w * scale > (float) max_w) + if ((float)orig_w * scale > (float)max_w) { scale = wscale; DEBUG_PRINTF("Too wide! Using wscale!\n"); - DEBUG_PRINTF("new size would be: %d x %d\n", (int) ((float) orig_w * scale), - (int) ((float) orig_h * scale)); + DEBUG_PRINTF("new size would be: %d x %d\n", (int)((float)orig_w * scale), (int)((float)orig_h * scale)); } } @@ -22326,8 +21390,7 @@ static SDL_Surface *myIMG_Load(const char *file) return (load_kpx(file)); #ifndef NOSVG } - else if (strlen(file) > 4 - && strcasecmp(file + strlen(file) - 4, ".svg") == 0) + else if (strlen(file) > 4 && strcasecmp(file + strlen(file) - 4, ".svg") == 0) { return (load_svg(file)); #endif @@ -22425,12 +21488,10 @@ static void load_magic_plugins(void) if (plc == MAGIC_PLACE_GLOBAL) magic_api_struct->data_directory = strdup(DATA_PREFIX); else if (plc == MAGIC_PLACE_LOCAL) - magic_api_struct->data_directory = - get_fname("plugins/data/", DIR_DATA); + magic_api_struct->data_directory = get_fname("plugins/data/", DIR_DATA); #ifdef __APPLE__ else if (plc == MAGIC_PLACE_ALLUSERS) - magic_api_struct->data_directory = - strdup("/Library/Application Support/TuxPaint/plugins/data"); + magic_api_struct->data_directory = strdup("/Library/Application Support/TuxPaint/plugins/data"); #endif else magic_api_struct->data_directory = strdup("./"); @@ -22484,204 +21545,126 @@ static void load_magic_plugins(void) { DEBUG_PRINTF("loading: %s\n", fname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "get_tool_count"); - magic_funcs[num_plugin_files].get_tool_count = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "get_tool_count"); + magic_funcs[num_plugin_files].get_tool_count = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "get_group"); - magic_funcs[num_plugin_files].get_group = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "get_group"); + magic_funcs[num_plugin_files].get_group = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "get_name"); - magic_funcs[num_plugin_files].get_name = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "get_name"); + magic_funcs[num_plugin_files].get_name = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "get_icon"); - magic_funcs[num_plugin_files].get_icon = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "get_icon"); + magic_funcs[num_plugin_files].get_icon = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "get_description"); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "get_description"); magic_funcs[num_plugin_files].get_description = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "requires_colors"); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "requires_colors"); magic_funcs[num_plugin_files].requires_colors = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "accepted_sizes"); - magic_funcs[num_plugin_files].accepted_sizes = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "accepted_sizes"); + magic_funcs[num_plugin_files].accepted_sizes = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "default_size"); - magic_funcs[num_plugin_files].default_size = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "default_size"); + magic_funcs[num_plugin_files].default_size = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "modes"); - magic_funcs[num_plugin_files].modes = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "modes"); + magic_funcs[num_plugin_files].modes = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "set_color"); - magic_funcs[num_plugin_files].set_color = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "set_color"); + magic_funcs[num_plugin_files].set_color = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "set_size"); - magic_funcs[num_plugin_files].set_size = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "set_size"); + magic_funcs[num_plugin_files].set_size = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "init"); - magic_funcs[num_plugin_files].init = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "init"); + magic_funcs[num_plugin_files].init = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "api_version"); - magic_funcs[num_plugin_files].api_version = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "api_version"); + magic_funcs[num_plugin_files].api_version = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "shutdown"); - magic_funcs[num_plugin_files].shutdown = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "shutdown"); + magic_funcs[num_plugin_files].shutdown = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "click"); - magic_funcs[num_plugin_files].click = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "click"); + magic_funcs[num_plugin_files].click = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "drag"); - magic_funcs[num_plugin_files].drag = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "drag"); + magic_funcs[num_plugin_files].drag = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "release"); - magic_funcs[num_plugin_files].release = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "release"); + magic_funcs[num_plugin_files].release = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "switchin"); - magic_funcs[num_plugin_files].switchin = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "switchin"); + magic_funcs[num_plugin_files].switchin = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); - safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, - "switchout"); - magic_funcs[num_plugin_files].switchout = - SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + safe_snprintf(funcname, sizeof(funcname), "%s_%s", objname, "switchout"); + magic_funcs[num_plugin_files].switchout = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); //EP added (intptr_t) to avoid warning on x64 on all lines below - DEBUG_PRINTF("get_tool_count = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].get_tool_count); - DEBUG_PRINTF("get_group = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].get_group); - DEBUG_PRINTF("get_name = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].get_name); - DEBUG_PRINTF("get_icon = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].get_icon); - DEBUG_PRINTF("get_description = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].get_description); - DEBUG_PRINTF("requires_colors = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].requires_colors); - DEBUG_PRINTF("accepted_sizes = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].accepted_sizes); - DEBUG_PRINTF("default_size = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].default_size); - DEBUG_PRINTF("modes = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].modes); - DEBUG_PRINTF("set_color = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].set_color); - DEBUG_PRINTF("set_size = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].set_size); - DEBUG_PRINTF("init = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].init); - DEBUG_PRINTF("api_version = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].api_version); - DEBUG_PRINTF("shutdown = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].shutdown); - DEBUG_PRINTF("click = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].click); - DEBUG_PRINTF("drag = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].drag); - DEBUG_PRINTF("release = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].release); - DEBUG_PRINTF("switchin = 0x%x\n", - (int) (intptr_t) magic_funcs[num_plugin_files].switchin); - DEBUG_PRINTF("switchout = 0x%x\n", - (int) (intptr_t) - magic_funcs[num_plugin_files].switchout); + DEBUG_PRINTF("get_tool_count = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_tool_count); + DEBUG_PRINTF("get_group = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_group); + DEBUG_PRINTF("get_name = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_name); + DEBUG_PRINTF("get_icon = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_icon); + DEBUG_PRINTF("get_description = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_description); + DEBUG_PRINTF("requires_colors = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].requires_colors); + DEBUG_PRINTF("accepted_sizes = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].accepted_sizes); + DEBUG_PRINTF("default_size = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].default_size); + DEBUG_PRINTF("modes = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].modes); + DEBUG_PRINTF("set_color = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].set_color); + DEBUG_PRINTF("set_size = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].set_size); + DEBUG_PRINTF("init = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].init); + DEBUG_PRINTF("api_version = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].api_version); + DEBUG_PRINTF("shutdown = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].shutdown); + DEBUG_PRINTF("click = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].click); + DEBUG_PRINTF("drag = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].drag); + DEBUG_PRINTF("release = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].release); + DEBUG_PRINTF("switchin = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].switchin); + DEBUG_PRINTF("switchout = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].switchout); err = 0; if (magic_funcs[num_plugin_files].get_tool_count == NULL) { - fprintf(stderr, - "Error: plugin %s is missing get_tool_count\n", - fname); + fprintf(stderr, "Error: plugin %s is missing get_tool_count\n", fname); err = 1; } if (magic_funcs[num_plugin_files].get_group == NULL) { - fprintf(stderr, "Error: plugin %s is missing get_group\n", - fname); + fprintf(stderr, "Error: plugin %s is missing get_group\n", fname); err = 1; } if (magic_funcs[num_plugin_files].get_name == NULL) { - fprintf(stderr, "Error: plugin %s is missing get_name\n", - fname); + fprintf(stderr, "Error: plugin %s is missing get_name\n", fname); err = 1; } if (magic_funcs[num_plugin_files].get_icon == NULL) { - fprintf(stderr, "Error: plugin %s is missing get_icon\n", - fname); + fprintf(stderr, "Error: plugin %s is missing get_icon\n", fname); err = 1; } if (magic_funcs[num_plugin_files].get_description == NULL) { - fprintf(stderr, - "Error: plugin %s is missing get_description\n", - fname); + fprintf(stderr, "Error: plugin %s is missing get_description\n", fname); err = 1; } if (magic_funcs[num_plugin_files].requires_colors == NULL) { - fprintf(stderr, - "Error: plugin %s is missing requires_colors\n", - fname); + fprintf(stderr, "Error: plugin %s is missing requires_colors\n", fname); err = 1; } if (magic_funcs[num_plugin_files].accepted_sizes == NULL) { - fprintf(stderr, - "Error: plugin %s is missing accepted_sizes\n", - fname); + fprintf(stderr, "Error: plugin %s is missing accepted_sizes\n", fname); err = 1; } if (magic_funcs[num_plugin_files].default_size == NULL) { - fprintf(stderr, - "Error: plugin %s is missing default_size\n", - fname); + fprintf(stderr, "Error: plugin %s is missing default_size\n", fname); err = 1; } if (magic_funcs[num_plugin_files].modes == NULL) @@ -22691,14 +21674,12 @@ static void load_magic_plugins(void) } if (magic_funcs[num_plugin_files].set_color == NULL) { - fprintf(stderr, "Error: plugin %s is missing set_color\n", - fname); + fprintf(stderr, "Error: plugin %s is missing set_color\n", fname); err = 1; } if (magic_funcs[num_plugin_files].set_size == NULL) { - fprintf(stderr, "Error: plugin %s is missing set_size\n", - fname); + fprintf(stderr, "Error: plugin %s is missing set_size\n", fname); err = 1; } if (magic_funcs[num_plugin_files].init == NULL) @@ -22708,8 +21689,7 @@ static void load_magic_plugins(void) } if (magic_funcs[num_plugin_files].shutdown == NULL) { - fprintf(stderr, "Error: plugin %s is missing shutdown\n", - fname); + fprintf(stderr, "Error: plugin %s is missing shutdown\n", fname); err = 1; } if (magic_funcs[num_plugin_files].click == NULL) @@ -22719,20 +21699,17 @@ static void load_magic_plugins(void) } if (magic_funcs[num_plugin_files].release == NULL) { - fprintf(stderr, "Error: plugin %s is missing release\n", - fname); + fprintf(stderr, "Error: plugin %s is missing release\n", fname); err = 1; } if (magic_funcs[num_plugin_files].switchin == NULL) { - fprintf(stderr, "Error: plugin %s is missing switchin\n", - fname); + fprintf(stderr, "Error: plugin %s is missing switchin\n", fname); err = 1; } if (magic_funcs[num_plugin_files].switchout == NULL) { - fprintf(stderr, "Error: plugin %s is missing switchout\n", - fname); + fprintf(stderr, "Error: plugin %s is missing switchout\n", fname); err = 1; } if (magic_funcs[num_plugin_files].drag == NULL) @@ -22743,17 +21720,14 @@ static void load_magic_plugins(void) if (magic_funcs[num_plugin_files].api_version == NULL) { - fprintf(stderr, "Error: plugin %s is missing api_version\n", - fname); + fprintf(stderr, "Error: plugin %s is missing api_version\n", fname); err = 1; } - else if (magic_funcs[num_plugin_files].api_version() != - TP_MAGIC_API_VERSION) + else if (magic_funcs[num_plugin_files].api_version() != TP_MAGIC_API_VERSION) { fprintf(stderr, "Warning: plugin %s uses Tux Paint 'Magic' tool API version %x,\nbut Tux Paint needs version %x.\n", - fname, magic_funcs[num_plugin_files].api_version(), - TP_MAGIC_API_VERSION); + fname, magic_funcs[num_plugin_files].api_version(), TP_MAGIC_API_VERSION); err = 1; } @@ -22766,9 +21740,7 @@ static void load_magic_plugins(void) res = magic_funcs[num_plugin_files].init(magic_api_struct, magic_disabled_features); if (res != 0) - n = - magic_funcs[num_plugin_files].get_tool_count - (magic_api_struct); + n = magic_funcs[num_plugin_files].get_tool_count(magic_api_struct); else { magic_funcs[num_plugin_files].shutdown(magic_api_struct); @@ -22778,9 +21750,7 @@ static void load_magic_plugins(void) if (n == 0) { - fprintf(stderr, - "Error: plugin %s failed to startup or reported 0 magic tools\n", - fname); + fprintf(stderr, "Error: plugin %s failed to startup or reported 0 magic tools\n", fname); fflush(stderr); SDL_UnloadObject(magic_handle[num_plugin_files]); } @@ -22791,9 +21761,7 @@ static void load_magic_plugins(void) for (i = 0; i < n; i++) { - group = - magic_funcs[num_plugin_files].get_group - (magic_api_struct, i); + group = magic_funcs[num_plugin_files].get_group(magic_api_struct, i); if (group < MAX_MAGIC_GROUPS) { idx = num_magics[group]; @@ -22802,47 +21770,35 @@ static void load_magic_plugins(void) magics[group][idx].place = plc; magics[group][idx].handle_idx = num_plugin_files; magics[group][idx].group = group; - magics[group][idx].name = - magic_funcs[num_plugin_files].get_name - (magic_api_struct, i); + magics[group][idx].name = magic_funcs[num_plugin_files].get_name(magic_api_struct, i); - magics[group][idx].avail_modes = - magic_funcs[num_plugin_files].modes(magic_api_struct, - i); + magics[group][idx].avail_modes = magic_funcs[num_plugin_files].modes(magic_api_struct, i); for (j = 0; j < MAX_MODES; j++) { magics[group][idx].tip[j] = NULL; if (j) { - if (magics[group][idx].avail_modes & - MODE_FULLSCREEN) + if (magics[group][idx].avail_modes & MODE_FULLSCREEN) magics[group][idx].tip[j] = - magic_funcs[num_plugin_files].get_description - (magic_api_struct, i, MODE_FULLSCREEN); + magic_funcs[num_plugin_files].get_description(magic_api_struct, i, MODE_FULLSCREEN); } else { if (magics[group][idx].avail_modes & MODE_PAINT) magics[group][idx].tip[j] = - magic_funcs[num_plugin_files].get_description - (magic_api_struct, i, MODE_PAINT); - else if (magics[group][idx].avail_modes & - MODE_ONECLICK) + magic_funcs[num_plugin_files].get_description(magic_api_struct, i, MODE_PAINT); + else if (magics[group][idx].avail_modes & MODE_ONECLICK) magics[group][idx].tip[j] = - magic_funcs[num_plugin_files].get_description - (magic_api_struct, i, MODE_ONECLICK); - else if (magics[group][idx].avail_modes & - MODE_PAINT_WITH_PREVIEW) + magic_funcs[num_plugin_files].get_description(magic_api_struct, i, MODE_ONECLICK); + else if (magics[group][idx].avail_modes & MODE_PAINT_WITH_PREVIEW) magics[group][idx].tip[j] = magic_funcs[num_plugin_files].get_description (magic_api_struct, i, MODE_PAINT_WITH_PREVIEW); } } - magics[group][idx].colors = - magic_funcs[num_plugin_files].requires_colors - (magic_api_struct, i); + magics[group][idx].colors = magic_funcs[num_plugin_files].requires_colors(magic_api_struct, i); for (j = 0; j < MAX_MODES; j++) { @@ -22850,31 +21806,41 @@ static void load_magic_plugins(void) mode_bit = 0; - if (j == 1 && magics[group][idx].avail_modes & MODE_FULLSCREEN) { + if (j == 1 && magics[group][idx].avail_modes & MODE_FULLSCREEN) + { mode_bit = MODE_FULLSCREEN; - } else { - if (magics[group][idx].avail_modes & MODE_PAINT) { + } + else + { + if (magics[group][idx].avail_modes & MODE_PAINT) + { mode_bit = MODE_PAINT; - } else if (magics[group][idx].avail_modes & MODE_ONECLICK) { + } + else if (magics[group][idx].avail_modes & MODE_ONECLICK) + { mode_bit = MODE_ONECLICK; - } else if (magics[group][idx].avail_modes & MODE_PAINT_WITH_PREVIEW) { + } + else if (magics[group][idx].avail_modes & MODE_PAINT_WITH_PREVIEW) + { mode_bit = MODE_PAINT_WITH_PREVIEW; } } - if (mode_bit != 0) { + if (mode_bit != 0) + { magics[group][idx].sizes[j] = - magic_funcs[num_plugin_files].accepted_sizes - (magic_api_struct, i, mode_bit); - if (magics[group][idx].sizes[j] > 1) { + magic_funcs[num_plugin_files].accepted_sizes(magic_api_struct, i, mode_bit); + if (magics[group][idx].sizes[j] > 1) + { magics[group][idx].default_size[j] = - magic_funcs[num_plugin_files].default_size - (magic_api_struct, i, mode_bit); + magic_funcs[num_plugin_files].default_size(magic_api_struct, i, mode_bit); if (magics[group][idx].default_size[j] < 1 || - magics[group][idx].default_size[j] > magics[group][idx].sizes[j]) { + magics[group][idx].default_size[j] > magics[group][idx].sizes[j]) + { fprintf(stderr, "Warning: plugin %s tool # %d for %d mode (%x) default size (%d) out of range (1-%d)\n", - fname, i, j, mode_bit, magics[group][idx].default_size[j], magics[group][idx].sizes[j]); + fname, i, j, mode_bit, magics[group][idx].default_size[j], + magics[group][idx].sizes[j]); magics[group][idx].default_size[j] = 1; } magics[group][idx].size[j] = magics[group][idx].default_size[j]; @@ -22886,35 +21852,28 @@ static void load_magic_plugins(void) magics[group][idx].mode = MODE_PAINT; else if (magics[group][idx].avail_modes & MODE_ONECLICK) magics[group][idx].mode = MODE_ONECLICK; - else if (magics[group][idx].avail_modes & - MODE_PAINT_WITH_PREVIEW) + else if (magics[group][idx].avail_modes & MODE_PAINT_WITH_PREVIEW) magics[group][idx].mode = MODE_PAINT_WITH_PREVIEW; else magics[group][idx].mode = MODE_FULLSCREEN; - icon_tmp = - magic_funcs[num_plugin_files].get_icon - (magic_api_struct, i); + icon_tmp = magic_funcs[num_plugin_files].get_icon(magic_api_struct, i); if (icon_tmp != NULL) { magics[group][idx].img_icon = thumbnail(icon_tmp, - 40 * button_w / ORIGINAL_BUTTON_SIZE, - 30 * button_h / ORIGINAL_BUTTON_SIZE, 1); + 40 * button_w / ORIGINAL_BUTTON_SIZE, 30 * button_h / ORIGINAL_BUTTON_SIZE, 1); SDL_FreeSurface(icon_tmp); DEBUG_PRINTF("-- %s\n", magics[group][idx].name); - DEBUG_PRINTF("avail_modes = %d\n", - magics[group][idx].avail_modes); + DEBUG_PRINTF("avail_modes = %d\n", magics[group][idx].avail_modes); num_magics[group]++; num_magics_total++; } else { - fprintf(stderr, - "Error: plugin %s mode # %d failed to load an icon\n", - fname, i); + fprintf(stderr, "Error: plugin %s mode # %d failed to load an icon\n", fname, i); fflush(stderr); } } @@ -22933,8 +21892,7 @@ static void load_magic_plugins(void) } else { - fprintf(stderr, "Warning: Failed to load object %s: %s\n", - fname, SDL_GetError()); + fprintf(stderr, "Warning: Failed to load object %s: %s\n", fname, SDL_GetError()); fflush(stderr); } } @@ -22952,8 +21910,7 @@ static void load_magic_plugins(void) qsort(magics[i], num_magics[i], sizeof(magic_t), magic_sort); } - DEBUG_PRINTF("Loaded %d magic tools from %d plug-in files\n", num_magics_total, - num_plugin_files); + DEBUG_PRINTF("Loaded %d magic tools from %d plug-in files\n", num_magics_total, num_plugin_files); DEBUG_PRINTF("\n"); } @@ -22985,10 +21942,7 @@ static void update_progress_bar(void) static void magic_line_func(void *mapi, int which, SDL_Surface * canvas, SDL_Surface * last, int x1, int y1, int x2, - int y2, int step, void (*cb)(void *, int, - SDL_Surface *, - SDL_Surface *, int, - int)) + int y2, int step, void (*cb)(void *, int, SDL_Surface *, SDL_Surface *, int, int)) { int dx, dy, y; float m, b; @@ -23001,7 +21955,7 @@ static void magic_line_func(void *mapi, if (dx != 0) { - m = ((float) dy) / ((float) dx); + m = ((float)dy) / ((float)dx); b = y1 - m * x1; if (x2 >= x1) @@ -23021,7 +21975,7 @@ static void magic_line_func(void *mapi, { cnt = (cnt + 1) % step; if (cnt == 0) - cb((void *) mapi, which, canvas, last, x1, y); + cb((void *)mapi, which, canvas, last, x1, y); } } else @@ -23030,7 +21984,7 @@ static void magic_line_func(void *mapi, { cnt = (cnt + 1) % step; if (cnt == 0) - cb((void *) mapi, which, canvas, last, x1, y); + cb((void *)mapi, which, canvas, last, x1, y); } } @@ -23045,7 +21999,7 @@ static void magic_line_func(void *mapi, { cnt = (cnt + 1) % step; if (cnt == 0) - cb((void *) mapi, which, canvas, last, x1, y); + cb((void *)mapi, which, canvas, last, x1, y); } } else @@ -23054,7 +22008,7 @@ static void magic_line_func(void *mapi, { cnt = (cnt + 1) % step; if (cnt == 0) - cb((void *) mapi, which, canvas, last, x1, y); + cb((void *)mapi, which, canvas, last, x1, y); } } } @@ -23249,7 +22203,7 @@ static int do_new_dialog(void) things_alloced = 32; - fs = (struct dirent2 *) malloc(sizeof(struct dirent2) * things_alloced); + fs = (struct dirent2 *)malloc(sizeof(struct dirent2) * things_alloced); num_files = 0; cur = 0; @@ -23259,8 +22213,7 @@ static int do_new_dialog(void) /* Open directories of images: */ - for (places_to_look = 0; places_to_look < NUM_PLACES_TO_LOOK; - places_to_look++) + for (places_to_look = 0; places_to_look < NUM_PLACES_TO_LOOK; places_to_look++) { if (places_to_look == PLACE_SAVED_DIR) { @@ -23309,8 +22262,7 @@ static int do_new_dialog(void) if (f != NULL) { - safe_snprintf(fname, sizeof(fname), "%s/%s", - dirname[places_to_look], f->d_name); + safe_snprintf(fname, sizeof(fname), "%s/%s", dirname[places_to_look], f->d_name); if (!stat(fname, &sbuf) && S_ISREG(sbuf.st_mode)) { memcpy(&(fs[num_files_in_dirs].f), f, sizeof(struct dirent)); @@ -23322,10 +22274,7 @@ static int do_new_dialog(void) { things_alloced = things_alloced + 32; - fs = - (struct dirent2 *) realloc(fs, - sizeof(struct dirent2) * - things_alloced); + fs = (struct dirent2 *)realloc(fs, sizeof(struct dirent2) * things_alloced); } } } @@ -23340,7 +22289,7 @@ static int do_new_dialog(void) /* Try inside android assets only if it is a relative path */ AAssetDir *ad = open_asset_dir(dirname[places_to_look]); - const char *afilename = (const char *) NULL; + const char *afilename = (const char *)NULL; while ((afilename = AAssetDir_getNextFileName(ad)) != NULL) { @@ -23356,10 +22305,7 @@ static int do_new_dialog(void) { things_alloced = things_alloced + 32; - fs = - (struct dirent2 *) realloc(fs, - sizeof(struct dirent2) * - things_alloced); + fs = (struct dirent2 *)realloc(fs, sizeof(struct dirent2) * things_alloced); } } } @@ -23374,16 +22320,15 @@ static int do_new_dialog(void) tot += NUM_COLORS; thumbs = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * tot); - d_places = (int *) malloc(sizeof(int) * tot); - d_names = (char **) malloc(sizeof(char *) * tot); - d_exts = (char **) malloc(sizeof(char *) * tot); + d_places = (int *)malloc(sizeof(int) * tot); + d_names = (char **)malloc(sizeof(char *) * tot); + d_exts = (char **)malloc(sizeof(char *) * tot); /* Sort: */ /* (N.B. "New" dialog not affected by 'reversesort' option) */ - qsort(fs, num_files_in_dirs, sizeof(struct dirent2), - (int (*)(const void *, const void *)) compare_dirent2s); + qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s); /* Throw the color palette at the beginning (default): */ @@ -23393,9 +22338,7 @@ static int do_new_dialog(void) if (!new_colors_last) { first_color = 0; - num_files = - do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, - &white_in_palette); + num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); } first_starter = num_files; @@ -23409,8 +22352,7 @@ static int do_new_dialog(void) f = &(fs[j].f); place = fs[j].place; - if ((place == PLACE_PERSONAL_TEMPLATES_DIR - || place == PLACE_TEMPLATES_DIR) && first_template == -1) + if ((place == PLACE_PERSONAL_TEMPLATES_DIR || place == PLACE_TEMPLATES_DIR) && first_template == -1) first_template = num_files; show_progress_bar(screen); @@ -23419,15 +22361,13 @@ static int do_new_dialog(void) { debug(f->d_name); - if (strcasestr(f->d_name, "-t.") == NULL - && strcasestr(f->d_name, "-back.") == NULL) + if (strcasestr(f->d_name, "-t.") == NULL && strcasestr(f->d_name, "-back.") == NULL) { if (strcasestr(f->d_name, FNAME_EXTENSION) != NULL /* Support legacy BMP files for load: */ || strcasestr(f->d_name, ".bmp") != NULL /* Support for KPX (Kid Pix templates; just a JPEG with resource fork header): */ - || strcasestr(f->d_name, ".kpx") != NULL - || strcasestr(f->d_name, ".jpg") != NULL + || strcasestr(f->d_name, ".kpx") != NULL || strcasestr(f->d_name, ".jpg") != NULL #ifndef NOSVG || strcasestr(f->d_name, ".svg") != NULL #endif @@ -23439,33 +22379,33 @@ static int do_new_dialog(void) if (strcasestr(fname, FNAME_EXTENSION) != NULL) { d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION)); - strcpy((char *) strcasestr(fname, FNAME_EXTENSION), ""); /* safe; truncating */ + strcpy((char *)strcasestr(fname, FNAME_EXTENSION), ""); /* safe; truncating */ } if (strcasestr(fname, ".bmp") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".bmp")); - strcpy((char *) strcasestr(fname, ".bmp"), ""); /* safe; truncating */ + strcpy((char *)strcasestr(fname, ".bmp"), ""); /* safe; truncating */ } #ifndef NOSVG if (strcasestr(fname, ".svg") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".svg")); - strcpy((char *) strcasestr(fname, ".svg"), ""); /* safe; truncating */ + strcpy((char *)strcasestr(fname, ".svg"), ""); /* safe; truncating */ } #endif if (strcasestr(fname, ".kpx") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".kpx")); - strcpy((char *) strcasestr(fname, ".kpx"), ""); /* safe; truncating */ + strcpy((char *)strcasestr(fname, ".kpx"), ""); /* safe; truncating */ } if (strcasestr(fname, ".jpg") != NULL) { d_exts[num_files] = strdup(strcasestr(fname, ".jpg")); - strcpy((char *) strcasestr(fname, ".jpg"), ""); /* safe; truncating */ + strcpy((char *)strcasestr(fname, ".jpg"), ""); /* safe; truncating */ } #ifndef NOSVG @@ -23481,8 +22421,7 @@ static int do_new_dialog(void) safe_strncpy(fname2, f2->d_name, sizeof(fname2)); if (strstr(fname2, fname) == fname2 - && strlen(fname) == strlen(fname2) - strlen(".svg") - && strcasestr(fname2, ".svg") != NULL) + && strlen(fname) == strlen(fname2) - strlen(".svg") && strcasestr(fname2, ".svg") != NULL) { /* SVG of this bitmap exists; we'll skip it */ skip = 1; @@ -23512,8 +22451,7 @@ static int do_new_dialog(void) /* No thumbnail in the new location ("saved/.thumbs"), try the old location ("saved/"): */ - safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", - dirname[d_places[num_files]], d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-t.png", dirname[d_places[num_files]], d_names[num_files]); debug(fname); img = IMG_Load(fname); @@ -23542,9 +22480,7 @@ static int do_new_dialog(void) if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of saved image!\n" - "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of saved image!\n" "%s\n", fname); } num_files++; @@ -23562,8 +22498,7 @@ static int do_new_dialog(void) "Can't create user data directory (for starters/templates) (E010)")) { /* (Make sure we have a .../[starters|templates]/.thumbs/ directory:) */ - safe_snprintf(fname, sizeof(fname), "%s/.thumbs", - dirname[d_places[num_files]]); + safe_snprintf(fname, sizeof(fname), "%s/.thumbs", dirname[d_places[num_files]]); make_directory(DIR_SAVE, fname, "Can't create user data thumbnail directory (for starters/templates) (E011)"); } @@ -23571,23 +22506,18 @@ static int do_new_dialog(void) img = NULL; - if (d_places[num_files] == PLACE_STARTERS_DIR || - d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR) + if (d_places[num_files] == PLACE_STARTERS_DIR || d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR) { /* Try to load a starter's background image, first! If it exists, it should give a better idea of what the starter looks like, compared to the overlay image... */ /* (Try JPEG first) */ - safe_snprintf(fname, sizeof(fname), "%s/%s-back", - dirname[d_places[num_files]], - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-back", dirname[d_places[num_files]], d_names[num_files]); img = load_starter_helper(fname, "jpeg", &IMG_Load); if (img == NULL) { - safe_snprintf(fname, sizeof(fname), "%s/%s-back", - dirname[d_places[num_files]], - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-back", dirname[d_places[num_files]], d_names[num_files]); img = load_starter_helper(fname, "jpg", &IMG_Load); } @@ -23595,9 +22525,7 @@ static int do_new_dialog(void) if (img == NULL) { /* (Try SVG next) */ - safe_snprintf(fname, sizeof(fname), "%s/%s-back", - dirname[d_places[num_files]], - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-back", dirname[d_places[num_files]], d_names[num_files]); img = load_starter_helper(fname, "svg", &load_svg); } #endif @@ -23605,9 +22533,7 @@ static int do_new_dialog(void) if (img == NULL) { /* (Try PNG next) */ - safe_snprintf(fname, sizeof(fname), "%s/%s-back", - dirname[d_places[num_files]], - d_names[num_files]); + safe_snprintf(fname, sizeof(fname), "%s/%s-back", dirname[d_places[num_files]], d_names[num_files]); img = load_starter_helper(fname, "png", &IMG_Load); } } @@ -23617,8 +22543,7 @@ static int do_new_dialog(void) /* Didn't load a starter background (or didn't try!), try loading the actual image... */ - safe_snprintf(fname, sizeof(fname), "%s/%s", - dirname[d_places[num_files]], f->d_name); + safe_snprintf(fname, sizeof(fname), "%s/%s", dirname[d_places[num_files]], f->d_name); debug(fname); img = myIMG_Load(fname); } @@ -23631,8 +22556,7 @@ static int do_new_dialog(void) fprintf(stderr, "\nWarning: I can't open one of the saved files!\n" "%s\n" - "The Simple DirectMedia Layer error that " - "occurred was:\n" "%s\n\n", fname, SDL_GetError()); + "The Simple DirectMedia Layer error that " "occurred was:\n" "%s\n\n", fname, SDL_GetError()); free(d_names[num_files]); free(d_exts[num_files]); @@ -23651,9 +22575,7 @@ static int do_new_dialog(void) SDL_FreeSurface(img2); if (thumbs[num_files] == NULL) { - fprintf(stderr, - "\nError: Couldn't create a thumbnail of saved image!\n" - "%s\n", fname); + fprintf(stderr, "\nError: Couldn't create a thumbnail of saved image!\n" "%s\n", fname); } SDL_FreeSurface(img); @@ -23671,8 +22593,7 @@ static int do_new_dialog(void) debug("Saving thumbnail for this one!"); safe_snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", - dirname[d_places[num_files]], - d_names[num_files]); + dirname[d_places[num_files]], d_names[num_files]); if (!make_directory (DIR_SAVE, "starters", @@ -23692,9 +22613,7 @@ static int do_new_dialog(void) fprintf(stderr, "\nError: Couldn't save thumbnail of " "saved image!\n" - "%s\n" - "The error that occurred was:\n" "%s\n\n", - fname, strerror(errno)); + "%s\n" "The error that occurred was:\n" "%s\n\n", fname, strerror(errno)); } else { @@ -23725,9 +22644,7 @@ static int do_new_dialog(void) if (new_colors_last) { first_color = num_files; - num_files = - do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, - &white_in_palette); + num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette); } @@ -23805,13 +22722,8 @@ static int do_new_dialog(void) - dest.x = - THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - - thumbs[i]->w) / 2; - dest.y = - THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - 20 - - thumbs[i]->h) / - 2; + dest.x = THUMB_W * ((i - cur) % 4) + r_ttools.w + 10 + (THUMB_W - 20 - thumbs[i]->w) / 2; + dest.y = THUMB_H * ((i - cur) / 4) + img_scroll_up->h + 10 + (THUMB_H - 20 - thumbs[i]->h) / 2; if (thumbs[i] != NULL) SDL_BlitSurface(thumbs[i], NULL, screen, &dest); @@ -23844,8 +22756,7 @@ static int do_new_dialog(void) SDL_BlitSurface(img_open, NULL, screen, &dest); dest.x = r_ttools.w + (button_w - img_openlabels_open->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_open->h; // FIXME: CROP LABELS + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_open->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_open, NULL, screen, &dest); @@ -23855,11 +22766,8 @@ static int do_new_dialog(void) dest.y = (button_h * buttons_tall + r_ttools.h) - button_h; SDL_BlitSurface(img_back, NULL, screen, &dest); - dest.x = - WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - - img_openlabels_back->w) / 2; - dest.y = - (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS + dest.x = WINDOW_WIDTH - r_ttoolopt.w - button_w + (button_w - img_openlabels_back->w) / 2; + dest.y = (button_h * buttons_tall + r_ttools.h) - img_openlabels_back->h; // FIXME: CROP LABELS SDL_BlitSurface(img_openlabels_back, NULL, screen, &dest); @@ -23968,20 +22876,16 @@ static int do_new_dialog(void) } else if ((event.type == SDL_MOUSEBUTTONDOWN - && valid_click(event.button.button)) - || event.type == TP_SDL_MOUSEBUTTONSCROLL) + && valid_click(event.button.button)) || event.type == TP_SDL_MOUSEBUTTONSCROLL) { if (event.button.x >= r_ttools.w && event.button.x < WINDOW_WIDTH - r_ttoolopt.w - && event.button.y >= img_scroll_up->h - && event.button.y < - (button_h * buttons_tall + r_ttools.h - button_h)) + && event.button.y >= img_scroll_up->h && event.button.y < (button_h * buttons_tall + r_ttools.h - button_h)) { /* Picked an icon! */ which = - ((event.button.x - r_ttools.w) / (THUMB_W) + - (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur; + ((event.button.x - r_ttools.w) / (THUMB_W) + (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur; if (which < num_files) { @@ -23990,8 +22894,7 @@ static int do_new_dialog(void) if (which == last_click_which && - SDL_GetTicks() < last_click_time + 1000 - && event.button.button == last_click_button) + SDL_GetTicks() < last_click_time + 1000 && event.button.button == last_click_button) { /* Double-click! */ @@ -24009,8 +22912,7 @@ static int do_new_dialog(void) if (event.button.y < img_scroll_up->h || (event.button.y >= (button_h * buttons_tall + r_ttools.h - button_h) - && event.button.y < - (button_h * buttons_tall + r_ttools.h - img_scroll_up->h))) + && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_up->h))) { /* Up or Down scroll button in New dialog: */ @@ -24022,8 +22924,7 @@ static int do_new_dialog(void) { cur = cur - 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur == 0) do_setcursor(cursor_arrow); @@ -24034,9 +22935,7 @@ static int do_new_dialog(void) } else if (event.button.y >= (button_h * buttons_tall + r_ttools.h - button_h) - && event.button.y < - (button_h * buttons_tall + r_ttools.h - - img_scroll_up->h)) + && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_up->h)) { /* Down scroll button: */ @@ -24044,8 +22943,7 @@ static int do_new_dialog(void) { cur = cur + 4; update_list = 1; - playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, - SNDDIST_NEAR); + playsound(screen, 1, SND_SCROLL, 1, SNDPOS_CENTER, SNDDIST_NEAR); if (cur >= num_files - 16) do_setcursor(cursor_arrow); @@ -24076,15 +22974,13 @@ static int do_new_dialog(void) scrolling_dialog = 1; scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } else { DEBUG_PRINTF("Continuing scrolling\n"); scrolltimer_dialog = - SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_dialog_callback, - (void *) &scrolltimer_dialog_event); + SDL_AddTimer(REPEAT_SPEED / 3, scrolltimer_dialog_callback, (void *)&scrolltimer_dialog_event); } } } @@ -24150,8 +23046,7 @@ static int do_new_dialog(void) if (event.button.y < img_scroll_up->h && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 && - event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur > 0) + event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur > 0) { /* Scroll up button: */ @@ -24162,8 +23057,7 @@ static int do_new_dialog(void) && event.button.y < (button_h * buttons_tall + r_ttools.h - img_scroll_up->h) && event.button.x >= (WINDOW_WIDTH - img_scroll_up->w) / 2 - && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 - && cur < num_files - 16) + && event.button.x <= (WINDOW_WIDTH + img_scroll_up->w) / 2 && cur < num_files - 16) { /* Scroll down button: */ @@ -24191,8 +23085,7 @@ static int do_new_dialog(void) (button_h * buttons_tall + r_ttools.h) - button_h && ((((event.button.x - r_ttools.w) / (THUMB_W) + - (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + - cur) < num_files)) + (((event.button.y - img_scroll_up->h) / THUMB_H) * 4)) + cur) < num_files)) { /* One of the thumbnails: */ @@ -24235,20 +23128,17 @@ static int do_new_dialog(void) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -24266,8 +23156,7 @@ static int do_new_dialog(void) if (do_prompt_image_snd(PROMPT_OPEN_SAVE_TXT, PROMPT_OPEN_SAVE_YES, PROMPT_OPEN_SAVE_NO, - img_tools[TOOL_SAVE], NULL, NULL, - SND_AREYOUSURE, screen->w / 2, screen->h / 2)) + img_tools[TOOL_SAVE], NULL, NULL, SND_AREYOUSURE, screen->w / 2, screen->h / 2)) { do_save(TOOL_NEW, 1, 0); } @@ -24286,22 +23175,20 @@ static int do_new_dialog(void) /* Clean stale text */ if (texttool_len > 0) - { - texttool_str[0] = L'\0'; - texttool_len = 0; - cursor_textwidth = 0; - } + { + texttool_str[0] = L'\0'; + texttool_len = 0; + cursor_textwidth = 0; + } if (which >= first_starter - && (first_template == -1 || which < first_template) - && (!new_colors_last || which < first_color)) + && (first_template == -1 || which < first_template) && (!new_colors_last || which < first_color)) { /* Load a starter: */ /* Figure out filename: */ - safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname[d_places[which]], - d_names[which], d_exts[which]); + safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname[d_places[which]], d_names[which], d_exts[which]); img = myIMG_Load(fname); @@ -24309,12 +23196,9 @@ static int do_new_dialog(void) { fprintf(stderr, "\nWarning: Couldn't load the saved image! (3)\n" - "%s\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", fname, SDL_GetError()); + "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", fname, SDL_GetError()); - do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", - 0, 0); + do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", 0, 0); } else { @@ -24357,27 +23241,22 @@ static int do_new_dialog(void) SDL_BlitSurface(img_starter, NULL, canvas, NULL); } } - else if (first_template != -1 && which >= first_template - && (!new_colors_last || which < first_color)) + else if (first_template != -1 && which >= first_template && (!new_colors_last || which < first_color)) { /* Load a template: */ /* Figure out filename: */ - safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname[d_places[which]], - d_names[which], d_exts[which]); + safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname[d_places[which]], d_names[which], d_exts[which]); img = myIMG_Load(fname); if (img == NULL) { fprintf(stderr, "\nWarning: Couldn't load the saved image! (4)\n" - "%s\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", fname, SDL_GetError()); + "%s\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", fname, SDL_GetError()); - do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", - 0, 0); + do_prompt(PROMPT_OPEN_UNOPENABLE_TXT, PROMPT_OPEN_UNOPENABLE_YES, "", 0, 0); } else { @@ -24462,9 +23341,7 @@ static int do_new_dialog(void) canvas_color_b = color_hexes[which][2]; } - SDL_FillRect(canvas, NULL, - SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, - canvas_color_b)); + SDL_FillRect(canvas, NULL, SDL_MapRGB(canvas->format, canvas_color_r, canvas_color_g, canvas_color_b)); cur_undo = 0; oldest_undo = 0; @@ -24483,8 +23360,7 @@ static int do_new_dialog(void) } } - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w - r_ttools.w, - button_h * buttons_tall + r_ttools.h); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w - r_ttools.w, button_h * buttons_tall + r_ttools.h); /* Clean up: */ @@ -24517,8 +23393,7 @@ static int do_new_dialog(void) but may be placed at the end with the "--newcolorslast" option. */ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, - int *d_places, char * *d_names, - char * *d_exts, int *white_in_palette) + int *d_places, char * *d_names, char * *d_exts, int *white_in_palette) { int j; int added; @@ -24540,8 +23415,7 @@ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, THUMB_W - 20, THUMB_H - 20, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, 0); + screen->format->Gmask, screen->format->Bmask, 0); if (thumbs[num_files] != NULL) { @@ -24555,8 +23429,7 @@ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, g = color_hexes[j][1]; b = color_hexes[j][2]; } - SDL_FillRect(thumbs[num_files], NULL, - SDL_MapRGB(thumbs[num_files]->format, r, g, b)); + SDL_FillRect(thumbs[num_files], NULL, SDL_MapRGB(thumbs[num_files]->format, r, g, b)); added = 1; } } @@ -24569,16 +23442,14 @@ static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, { /* Color picker: */ - thumbs[num_files] = - thumbnail(img_color_picker, THUMB_W - 20, THUMB_H - 20, 0); + thumbs[num_files] = thumbnail(img_color_picker, THUMB_W - 20, THUMB_H - 20, 0); added = 1; } else if (j == COLOR_MIXER) { /* Color mixer: */ - thumbs[num_files] = - thumbnail(img_color_mix, THUMB_W - 20, THUMB_H - 20, 0); + thumbs[num_files] = thumbnail(img_color_mix, THUMB_W - 20, THUMB_H - 20, 0); added = 1; } @@ -24667,6 +23538,7 @@ static int do_color_sel(int temp_mode) SDL_Rect color_example_dest; SDL_Surface *backup; SDL_Rect r_color_picker; + Uint32(*getpixel_img_color_picker) (SDL_Surface *, int, int); if (!temp_mode) @@ -24694,8 +23566,7 @@ static int do_color_sel(int temp_mode) backup = SDL_CreateRGBSurface(screen->flags, screen->w, screen->h, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_BlitSurface(screen, NULL, backup, NULL); @@ -24729,8 +23600,7 @@ static int do_color_sel(int temp_mode) dest.w = i * r_color_sel.w / number_of_steps; dest.h = i * r_color_sel.h / number_of_steps; - SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255 - w, 255 - w, 255 - w)); + SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255 - w, 255 - w, 255 - w)); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); SDL_Delay(2); } @@ -24745,14 +23615,11 @@ static int do_color_sel(int temp_mode) r_color_sel.h, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); if (alpha_surf != NULL) { - SDL_FillRect(alpha_surf, NULL, - SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); + SDL_FillRect(alpha_surf, NULL, SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); for (i = 8; i > 0; i = i - 2) { @@ -24771,8 +23638,7 @@ static int do_color_sel(int temp_mode) /* Draw prompt box: */ - SDL_FillRect(screen, &r_color_sel, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &r_color_sel, SDL_MapRGB(screen->format, 255, 255, 255)); @@ -24783,16 +23649,14 @@ static int do_color_sel(int temp_mode) color_example_dest.w = r_color_sel.w - button_w - 8; color_example_dest.h = r_color_sel.h - 4; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 0, 0, 0)); color_example_dest.x += 2; color_example_dest.y += 2; color_example_dest.w -= 4; color_example_dest.h -= 4; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 255, 255, 255)); color_example_dest.x += 2; color_example_dest.y += 2; @@ -24808,8 +23672,7 @@ static int do_color_sel(int temp_mode) SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, color_hexes[COLOR_SELECTOR][0], - color_hexes[COLOR_SELECTOR][1], - color_hexes[COLOR_SELECTOR][2])); + color_hexes[COLOR_SELECTOR][1], color_hexes[COLOR_SELECTOR][2])); /* Show "Back" button */ back_left = r_color_sel.x + r_color_sel.w - button_w - 4; @@ -24855,8 +23718,7 @@ static int do_color_sel(int temp_mode) Needs testing on other operating sistems with touchscreen. */ if (!temp_mode) - SDL_WarpMouse(r_color_sel.x + r_color_sel.w / 2, - r_color_sel.y + r_color_sel.h / 2); + SDL_WarpMouse(r_color_sel.x + r_color_sel.w / 2, r_color_sel.y + r_color_sel.h / 2); #endif mouse_was_down = temp_mode; @@ -24903,8 +23765,7 @@ static int do_color_sel(int temp_mode) { if (event.button.x >= r_canvas.x && event.button.x < r_canvas.x + r_canvas.w && - event.button.y >= r_canvas.y - && event.button.y < r_canvas.y + r_canvas.h) + event.button.y >= r_canvas.y && event.button.y < r_canvas.y + r_canvas.h) { /* Picked a color in the canvas, and released! */ @@ -24923,8 +23784,7 @@ static int do_color_sel(int temp_mode) { if (event.button.x >= back_left && event.button.x < back_left + img_back->w && - event.button.y >= back_top - && event.button.y < back_top + img_back->h) + event.button.y >= back_top && event.button.y < back_top + img_back->h) { /* Full UI mode: Decided to go Back; abort */ @@ -24946,8 +23806,7 @@ static int do_color_sel(int temp_mode) { if (event.button.x >= r_canvas.x && event.button.x < r_canvas.x + r_canvas.w && - event.button.y >= r_canvas.y - && event.button.y < r_canvas.y + r_canvas.h) + event.button.y >= r_canvas.y && event.button.y < r_canvas.y + r_canvas.h) { /* Hovering over the canvas! */ @@ -24959,18 +23818,13 @@ static int do_color_sel(int temp_mode) x = event.button.x - r_canvas.x; y = event.button.y - r_canvas.y; - getpixel_img_color_picker = - getpixels[canvas->format->BytesPerPixel]; - SDL_GetRGB(getpixel_img_color_picker(canvas, x, y), canvas->format, - &r, &g, &b); + getpixel_img_color_picker = getpixels[canvas->format->BytesPerPixel]; + SDL_GetRGB(getpixel_img_color_picker(canvas, x, y), canvas->format, &r, &g, &b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, r, g, b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, r, g, b)); SDL_UpdateRect(screen, - color_example_dest.x, - color_example_dest.y, color_example_dest.w, - color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); } else { @@ -24984,21 +23838,17 @@ static int do_color_sel(int temp_mode) SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, color_hexes[COLOR_SELECTOR][0], - color_hexes[COLOR_SELECTOR][1], - color_hexes[COLOR_SELECTOR][2])); + color_hexes[COLOR_SELECTOR][1], color_hexes[COLOR_SELECTOR][2])); SDL_UpdateRect(screen, - color_example_dest.x, - color_example_dest.y, color_example_dest.w, - color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); /* Change cursor to arrow (or hand, if over Back): */ if (event.button.x >= back_left && event.button.x < back_left + img_back->w && - event.button.y >= back_top - && event.button.y < back_top + img_back->h) + event.button.y >= back_top && event.button.y < back_top + img_back->h) do_setcursor(cursor_hand); else do_setcursor(cursor_arrow); @@ -25012,20 +23862,17 @@ static int do_color_sel(int temp_mode) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -25037,8 +23884,7 @@ static int do_color_sel(int temp_mode) if (chose) { getpixel_img_color_picker = getpixels[canvas->format->BytesPerPixel]; - SDL_GetRGB(getpixel_img_color_picker(canvas, color_sel_x, color_sel_y), - canvas->format, &r, &g, &b); + SDL_GetRGB(getpixel_img_color_picker(canvas, color_sel_x, color_sel_y), canvas->format, &r, &g, &b); color_hexes[COLOR_SELECTOR][0] = r; color_hexes[COLOR_SELECTOR][1] = g; @@ -25056,7 +23902,8 @@ static int do_color_sel(int temp_mode) * (Eventually, we'll be able to detect tablet stylus erasers; * but waiting for https://github.com/libsdl-org/SDL/issues/2217) */ -static void do_quick_eraser(void) { +static void do_quick_eraser(void) +{ SDL_Event event; SDLKey key; int val_x, val_y, motioner; @@ -25114,8 +23961,7 @@ static void do_quick_eraser(void) { if (event.button.x >= r_canvas.x && event.button.x < r_canvas.x + r_canvas.w && - event.button.y >= r_canvas.y - && event.button.y < r_canvas.y + r_canvas.h) + event.button.y >= r_canvas.y && event.button.y < r_canvas.y + r_canvas.h) { do_setcursor(cursor_crosshair); eraser_draw(oldpos_x - r_canvas.x, oldpos_y - r_canvas.y, @@ -25129,20 +23975,17 @@ static void do_quick_eraser(void) { handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -25167,6 +24010,7 @@ static int do_color_picker(int prev_color) int val_x, val_y, motioner; int valhat_x, valhat_y, hatmotioner; int stop; + Uint32(*getpixel_img_color_picker) (SDL_Surface *, int, int); Uint8 r, g, b; int done, chose; @@ -25182,6 +24026,7 @@ static int do_color_picker(int prev_color) SDL_Surface *backup; SDL_Rect r_color_picker; SDL_Rect r_final; + val_x = val_y = motioner = 0; valhat_x = valhat_y = hatmotioner = 0; int old_cp_x, old_cp_y, old_cp_v; @@ -25196,8 +24041,7 @@ static int do_color_picker(int prev_color) do_setcursor(cursor_hand); - getpixel_img_color_picker = - getpixels[img_color_picker->format->BytesPerPixel]; + getpixel_img_color_picker = getpixels[img_color_picker->format->BytesPerPixel]; /* Draw button box: */ @@ -25207,8 +24051,7 @@ static int do_color_picker(int prev_color) backup = SDL_CreateRGBSurface(screen->flags, screen->w, screen->h, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_BlitSurface(screen, NULL, backup, NULL); @@ -25230,9 +24073,8 @@ static int do_color_picker(int prev_color) dest.h = w * 2; SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255 - (int) (w / button_scale), - 255 - (int) (w / button_scale), - 255 - (int) (w / button_scale))); + SDL_MapRGB(screen->format, 255 - (int)(w / button_scale), + 255 - (int)(w / button_scale), 255 - (int)(w / button_scale))); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); if (w % 16 == 0) @@ -25247,14 +24089,11 @@ static int do_color_picker(int prev_color) r_final.h + 16, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); if (alpha_surf != NULL) { - SDL_FillRect(alpha_surf, NULL, - SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); + SDL_FillRect(alpha_surf, NULL, SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); for (i = 8; i > 0; i = i - 2) { @@ -25309,23 +24148,20 @@ static int do_color_picker(int prev_color) /* Determine spot for example color: */ - color_example_dest.x = - color_picker_left + img_color_picker->w + 2 + img_back->w + 2; + color_example_dest.x = color_picker_left + img_color_picker->w + 2 + img_back->w + 2; color_example_dest.y = color_picker_top + 2; color_example_dest.w = r_final.w / 2 - 2 - img_back->w - 2; color_example_dest.h = r_final.h / 2 - 4; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 0, 0, 0)); color_example_dest.x += 2; color_example_dest.y += 2; color_example_dest.w -= 4; color_example_dest.h -= 4; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 255, 255, 255)); color_example_dest.x += 2; color_example_dest.y += 2; @@ -25337,9 +24173,7 @@ static int do_color_picker(int prev_color) SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, - color_hexes[COLOR_PICKER][0], - color_hexes[COLOR_PICKER][1], - color_hexes[COLOR_PICKER][2])); + color_hexes[COLOR_PICKER][0], color_hexes[COLOR_PICKER][1], color_hexes[COLOR_PICKER][2])); /* Draw buttons to pull colors from other sources: */ @@ -25349,7 +24183,8 @@ static int do_color_picker(int prev_color) prev_color_left = r_final.x + r_final.w - (img_back->w + 2) * 3; prev_color_top = color_picker_top + img_color_picker->h - (img_back->h + 2) * 2; - if (prev_color != -1 && prev_color < NUM_DEFAULT_COLORS) { + if (prev_color != -1 && prev_color < NUM_DEFAULT_COLORS) + { dest.x = prev_color_left; dest.y = prev_color_top; dest.w = img_back->w; @@ -25430,8 +24265,7 @@ static int do_color_picker(int prev_color) so we avoid updating parts of the screen where the crosshairs extend past the rainbow rectangle or value slider, since this function does not (yet) do any clipping) */ - draw_color_picker_crosshairs(color_picker_left, color_picker_top, - color_picker_val_left, color_picker_val_top); + draw_color_picker_crosshairs(color_picker_left, color_picker_top, color_picker_val_left, color_picker_val_top); dest.x = color_picker_left; dest.y = color_picker_top; @@ -25484,13 +24318,11 @@ static int do_color_picker(int prev_color) done = 1; } } - else if (event.type == SDL_MOUSEBUTTONUP - && valid_click(event.button.button)) + else if (event.type == SDL_MOUSEBUTTONUP && valid_click(event.button.button)) { if (event.button.x >= color_picker_left && event.button.x < color_picker_left + img_color_picker->w && - event.button.y >= color_picker_top && - event.button.y < color_picker_top + img_color_picker->h) + event.button.y >= color_picker_top && event.button.y < color_picker_top + img_color_picker->h) { /* Picked a color! */ @@ -25501,15 +24333,12 @@ static int do_color_picker(int prev_color) color_picker_y = y; /* Update (entire) color box */ - SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), - img_color_picker->format, &r, &g, &b); + SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), img_color_picker->format, &r, &g, &b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, r, g, b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, r, g, b)); SDL_UpdateRect(screen, - color_example_dest.x, color_example_dest.y, - color_example_dest.w, color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); /* Reposition hue/sat crosshair */ @@ -25517,15 +24346,13 @@ static int do_color_picker(int prev_color) dest.y = color_picker_top; SDL_BlitSurface(img_color_picker, NULL, screen, &dest); draw_color_picker_crosshairs(color_picker_left, color_picker_top, - color_picker_val_left, - color_picker_val_top); + color_picker_val_left, color_picker_val_top); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); } else if (event.button.x >= color_picker_val_left && event.button.y >= color_picker_val_top && event.button.x <= color_picker_val_left + img_back->w && - event.button.y <= - color_picker_val_top + img_color_picker_val->h) + event.button.y <= color_picker_val_top + img_color_picker_val->h) { /* Picked a value from the slider */ @@ -25537,27 +24364,21 @@ static int do_color_picker(int prev_color) /* Update (entire) color box */ SDL_GetRGB(getpixel_img_color_picker - (img_color_picker, color_picker_x, color_picker_y), - img_color_picker->format, &r, &g, &b); + (img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, r, g, b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, r, g, b)); SDL_UpdateRect(screen, - color_example_dest.x, color_example_dest.y, - color_example_dest.w, color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); /* Redraw hue/sat palette, and val slider, and redraw crosshairs */ draw_color_picker_palette_and_values(color_picker_left, - color_picker_top, - color_picker_val_left, - color_picker_val_top); + color_picker_top, color_picker_val_left, color_picker_val_top); } else if (event.button.x >= done_left && event.button.x < done_left + img_yes->w && - event.button.y >= done_top - && event.button.y < done_top + img_yes->h) + event.button.y >= done_top && event.button.y < done_top + img_yes->h) { /* Accepting color */ @@ -25566,8 +24387,7 @@ static int do_color_picker(int prev_color) } else if (event.button.x >= back_left && event.button.x < back_left + img_back->w && - event.button.y >= back_top - && event.button.y < back_top + img_back->h) + event.button.y >= back_top && event.button.y < back_top + img_back->h) { /* Decided to go Back */ @@ -25585,32 +24405,33 @@ static int do_color_picker(int prev_color) event.button.y < pipette_top + img_back->h) || (event.button.x >= mixer_left && event.button.x < mixer_left + img_back->w && - event.button.y >= mixer_top && - event.button.y < mixer_top + img_back->h)) + event.button.y >= mixer_top && event.button.y < mixer_top + img_back->h)) { int c; float h, s, v; if (event.button.x >= prev_color_left && event.button.x < prev_color_left + img_back->w && - event.button.y >= prev_color_top && - event.button.y < prev_color_top + img_back->h) { + event.button.y >= prev_color_top && event.button.y < prev_color_top + img_back->h) + { /* Switch to the chosen bucket color */ c = prev_color; - } else if (event.button.x >= pipette_left && - event.button.x < pipette_left + img_back->w && - event.button.y >= pipette_top && - event.button.y < pipette_top + img_back->h) { + } + else if (event.button.x >= pipette_left && + event.button.x < pipette_left + img_back->w && + event.button.y >= pipette_top && event.button.y < pipette_top + img_back->h) + { /* Pipette */ c = NUM_DEFAULT_COLORS; - } else { + } + else + { /* Mixer */ c = NUM_DEFAULT_COLORS + 2; } /* Convert the chosen color to HSV & reposition crosshairs */ - rgbtohsv(color_hexes[c][0], color_hexes[c][1], color_hexes[c][2], - &h, &s, &v); + rgbtohsv(color_hexes[c][0], color_hexes[c][1], color_hexes[c][2], &h, &s, &v); color_picker_v = (img_color_picker_val->h * (1.0 - v)); color_picker_x = (img_color_picker->w * s); @@ -25621,22 +24442,17 @@ static int do_color_picker(int prev_color) /* Update (entire) color box */ SDL_GetRGB(getpixel_img_color_picker - (img_color_picker, color_picker_x, color_picker_y), - img_color_picker->format, &r, &g, &b); + (img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, r, g, b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, r, g, b)); SDL_UpdateRect(screen, - color_example_dest.x, color_example_dest.y, - color_example_dest.w, color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); /* Redraw hue/sat palette, and val slider, and redraw crosshairs */ draw_color_picker_palette_and_values(color_picker_left, - color_picker_top, - color_picker_val_left, - color_picker_val_top); + color_picker_top, color_picker_val_left, color_picker_val_top); playsound(screen, 1, SND_BUBBLE, 1, SNDPOS_CENTER, SNDDIST_NEAR); } @@ -25668,8 +24484,7 @@ static int do_color_picker(int prev_color) y = event.button.y - color_picker_top; SDL_GetRGB(getpixel_img_color_picker - (img_color_picker, color_picker_x, color_picker_y), - img_color_picker->format, &r, &g, &b); + (img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); dest.x = color_example_dest.x + color_example_dest.w / 4; dest.y = color_example_dest.y + color_example_dest.h / 4; @@ -25683,9 +24498,7 @@ static int do_color_picker(int prev_color) /* Redraw hue/sat palette, and val slider, and redraw crosshairs */ draw_color_picker_palette_and_values(color_picker_left, - color_picker_top, - color_picker_val_left, - color_picker_val_top); + color_picker_top, color_picker_val_left, color_picker_val_top); last_motion_within_val_slider = 1; } @@ -25695,16 +24508,13 @@ static int do_color_picker(int prev_color) { render_color_picker_palette(); draw_color_picker_palette_and_values(color_picker_left, - color_picker_top, - color_picker_val_left, - color_picker_val_top); + color_picker_top, color_picker_val_left, color_picker_val_top); last_motion_within_val_slider = 0; } if (event.button.x >= color_picker_left && event.button.x < color_picker_left + img_color_picker->w && - event.button.y >= color_picker_top - && event.button.y < color_picker_top + img_color_picker->h) + event.button.y >= color_picker_top && event.button.y < color_picker_top + img_color_picker->h) { /* Hovering over the colors! */ @@ -25716,8 +24526,7 @@ static int do_color_picker(int prev_color) x = event.button.x - color_picker_left; y = event.button.y - color_picker_top; - SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), - img_color_picker->format, &r, &g, &b); + SDL_GetRGB(getpixel_img_color_picker(img_color_picker, x, y), img_color_picker->format, &r, &g, &b); dest.x = color_example_dest.x + color_example_dest.w / 4; dest.y = color_example_dest.y + color_example_dest.h / 4; @@ -25733,22 +24542,18 @@ static int do_color_picker(int prev_color) /* Revert to current color picker color */ SDL_GetRGB(getpixel_img_color_picker - (img_color_picker, color_picker_x, color_picker_y), - img_color_picker->format, &r, &g, &b); + (img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, r, g, b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, r, g, b)); SDL_UpdateRect(screen, - color_example_dest.x, color_example_dest.y, - color_example_dest.w, color_example_dest.h); + color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); /* Change cursor to arrow (or hand, if over Back or Done): */ if (event.button.x >= back_left && event.button.x < back_left + img_back->w && - event.button.y >= back_top - && event.button.y < back_top + img_back->h) + event.button.y >= back_top && event.button.y < back_top + img_back->h) do_setcursor(cursor_hand); else if ((event.button.x >= prev_color_left && event.button.x < prev_color_left + img_back->w && @@ -25761,13 +24566,11 @@ static int do_color_picker(int prev_color) event.button.y < pipette_top + img_back->h) || (event.button.x >= mixer_left && event.button.x < mixer_left + img_back->w && - event.button.y >= mixer_top && - event.button.y < mixer_top + img_back->h)) + event.button.y >= mixer_top && event.button.y < mixer_top + img_back->h)) do_setcursor(cursor_hand); else if (event.button.x >= done_left && event.button.x < done_left + img_yes->w && - event.button.y >= done_top - && event.button.y < done_top + img_yes->h) + event.button.y >= done_top && event.button.y < done_top + img_yes->h) do_setcursor(cursor_hand); else do_setcursor(cursor_arrow); @@ -25781,20 +24584,17 @@ static int do_color_picker(int prev_color) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -25805,8 +24605,7 @@ static int do_color_picker(int prev_color) { /* Set the new color: */ SDL_GetRGB(getpixel_img_color_picker - (img_color_picker, color_picker_x, color_picker_y), - img_color_picker->format, &r, &g, &b); + (img_color_picker, color_picker_x, color_picker_y), img_color_picker->format, &r, &g, &b); color_hexes[COLOR_PICKER][0] = r; color_hexes[COLOR_PICKER][1] = g; @@ -25836,8 +24635,7 @@ static int do_color_picker(int prev_color) static void draw_color_picker_palette_and_values(int color_picker_left, int color_picker_top, - int color_picker_val_left, - int color_picker_val_top) + int color_picker_val_left, int color_picker_val_top) { SDL_Rect dest; @@ -25848,8 +24646,7 @@ static void draw_color_picker_palette_and_values(int color_picker_left, SDL_BlitSurface(img_color_picker, NULL, screen, &dest); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); - draw_color_picker_crosshairs(color_picker_left, color_picker_top, - color_picker_val_left, color_picker_val_top); + draw_color_picker_crosshairs(color_picker_left, color_picker_top, color_picker_val_left, color_picker_val_top); dest.x = color_picker_val_left; dest.y = color_picker_val_top; @@ -25876,13 +24673,10 @@ static void render_color_picker_palette(void) { for (x = 0; x < img_color_picker->w; x++) { - hsvtorgb((((float) y * 360.0) / ((float) img_color_picker->h)), - ((float) x / ((float) img_color_picker->w)), - 1.0 - - (((float) color_picker_v) / ((float) img_color_picker_val->h)), - &r, &g, &b); - putpixel(img_color_picker, x, y, - SDL_MapRGBA(img_color_picker->format, r, g, b, 255)); + hsvtorgb((((float)y * 360.0) / ((float)img_color_picker->h)), + ((float)x / ((float)img_color_picker->w)), + 1.0 - (((float)color_picker_v) / ((float)img_color_picker_val->h)), &r, &g, &b); + putpixel(img_color_picker, x, y, SDL_MapRGBA(img_color_picker->format, r, g, b, 255)); } } @@ -25903,7 +24697,7 @@ int CROSSHAIR_LENGTH, CROSSHAIR_THICKNESS, CROSSHAIR_BORDER; static void set_color_picker_crosshair_size(void) { - CROSSHAIR_LENGTH = (int) (11 * button_scale); + CROSSHAIR_LENGTH = (int)(11 * button_scale); CROSSHAIR_LENGTH /= 2; CROSSHAIR_LENGTH *= 2; CROSSHAIR_LENGTH++; @@ -25912,7 +24706,7 @@ static void set_color_picker_crosshair_size(void) CROSSHAIR_LENGTH = 3; - CROSSHAIR_THICKNESS = (int) (button_scale); + CROSSHAIR_THICKNESS = (int)(button_scale); CROSSHAIR_THICKNESS /= 2; CROSSHAIR_THICKNESS *= 2; CROSSHAIR_THICKNESS++; @@ -25930,32 +24724,22 @@ static void set_color_picker_crosshair_size(void) } static void draw_color_picker_crosshairs(int color_picker_left, - int color_picker_top, - int color_picker_val_left, - int color_picker_val_top) + int color_picker_top, int color_picker_val_left, int color_picker_val_top) { SDL_Rect dest; int ctr_x; /* Hue/Saturation (the big rectangle) */ - dest.x = - color_picker_x + color_picker_left - (CROSSHAIR_LENGTH - 1) / 2 - - CROSSHAIR_BORDER; - dest.y = - color_picker_y + color_picker_top - (CROSSHAIR_THICKNESS - 1) / 2 - - CROSSHAIR_BORDER; + dest.x = color_picker_x + color_picker_left - (CROSSHAIR_LENGTH - 1) / 2 - CROSSHAIR_BORDER; + dest.y = color_picker_y + color_picker_top - (CROSSHAIR_THICKNESS - 1) / 2 - CROSSHAIR_BORDER; dest.w = CROSSHAIR_LENGTH + CROSSHAIR_BORDER * 2; dest.h = CROSSHAIR_THICKNESS + CROSSHAIR_BORDER * 2; SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 0, 0)); - dest.x = - color_picker_x + color_picker_left - (CROSSHAIR_THICKNESS - 1) / 2 - - CROSSHAIR_BORDER; - dest.y = - color_picker_y + color_picker_top - (CROSSHAIR_LENGTH - 1) / 2 - - CROSSHAIR_BORDER; + dest.x = color_picker_x + color_picker_left - (CROSSHAIR_THICKNESS - 1) / 2 - CROSSHAIR_BORDER; + dest.y = color_picker_y + color_picker_top - (CROSSHAIR_LENGTH - 1) / 2 - CROSSHAIR_BORDER; dest.w = CROSSHAIR_THICKNESS + CROSSHAIR_BORDER * 2; dest.h = CROSSHAIR_LENGTH + CROSSHAIR_BORDER * 2; @@ -25983,18 +24767,14 @@ static void draw_color_picker_crosshairs(int color_picker_left, ctr_x = color_picker_val_left + img_back->w / 2; dest.x = ctr_x - (CROSSHAIR_LENGTH - 1) / 2 - CROSSHAIR_BORDER; - dest.y = - color_picker_v + color_picker_val_top - (CROSSHAIR_THICKNESS - 1) / 2 - - CROSSHAIR_BORDER; + dest.y = color_picker_v + color_picker_val_top - (CROSSHAIR_THICKNESS - 1) / 2 - CROSSHAIR_BORDER; dest.w = CROSSHAIR_LENGTH + CROSSHAIR_BORDER * 2; dest.h = CROSSHAIR_THICKNESS + CROSSHAIR_BORDER * 2; SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0, 0, 0)); dest.x = ctr_x - (CROSSHAIR_THICKNESS - 1) / 2 - CROSSHAIR_BORDER; - dest.y = - color_picker_v + color_picker_val_top - (CROSSHAIR_LENGTH - 1) / 2 - - CROSSHAIR_BORDER; + dest.y = color_picker_v + color_picker_val_top - (CROSSHAIR_LENGTH - 1) / 2 - CROSSHAIR_BORDER; dest.w = CROSSHAIR_THICKNESS + CROSSHAIR_BORDER * 2; dest.h = CROSSHAIR_LENGTH + CROSSHAIR_BORDER * 2; @@ -26002,8 +24782,7 @@ static void draw_color_picker_crosshairs(int color_picker_left, dest.x = ctr_x - (CROSSHAIR_LENGTH - 1) / 2; - dest.y = - color_picker_v + color_picker_val_top - (CROSSHAIR_THICKNESS - 1) / 2; + dest.y = color_picker_v + color_picker_val_top - (CROSSHAIR_THICKNESS - 1) / 2; dest.w = CROSSHAIR_LENGTH; dest.h = CROSSHAIR_THICKNESS; @@ -26032,16 +24811,20 @@ static void draw_color_picker_values(int l, int t) } -static void draw_color_grab_btn(SDL_Rect dest, int c) { +static void draw_color_grab_btn(SDL_Rect dest, int c) +{ int x, y; Uint8 cr, cg, cb, r, g, b, a, tmp; + Uint32(*getpixel_btn) (SDL_Surface *, int, int); Uint32(*getpixel_scrn) (SDL_Surface *, int, int); - void (*putpixel_scrn) (SDL_Surface *, int, int, Uint32); + void (*putpixel_scrn)(SDL_Surface *, int, int, Uint32); SDL_Rect outline_dest; - for (y = -1; y <= 1; y++) { - for (x = -1; x <= 1; x++) { + for (y = -1; y <= 1; y++) + { + for (x = -1; x <= 1; x++) + { outline_dest.x = dest.x + x; outline_dest.y = dest.y + y; outline_dest.w = dest.w; @@ -26061,8 +24844,10 @@ static void draw_color_grab_btn(SDL_Rect dest, int c) { SDL_LockSurface(screen); SDL_LockSurface(img_color_grab); - for (y = 0; y < dest.h && y < img_color_grab->h; y++) { - for (x = 0; x < dest.w && x < img_color_grab->w; x++) { + for (y = 0; y < dest.h && y < img_color_grab->h; y++) + { + for (x = 0; x < dest.w && x < img_color_grab->w; x++) + { SDL_GetRGBA(getpixel_btn(img_color_grab, x, y), img_color_grab->format, &tmp, &tmp, &tmp, &a); SDL_GetRGBA(getpixel_scrn(screen, dest.x + x, dest.y + y), screen->format, &r, &g, &b, &tmp); @@ -26095,8 +24880,7 @@ enum }; SDL_Rect color_example_dest; -int color_mix_btn_lefts[NUM_COLOR_MIXER_BTNS], - color_mix_btn_tops[NUM_COLOR_MIXER_BTNS]; +int color_mix_btn_lefts[NUM_COLOR_MIXER_BTNS], color_mix_btn_tops[NUM_COLOR_MIXER_BTNS]; /* Hue (degrees 0-360, or -1 for N/A), Saturation (0.0-1.0), Value (0.0-1.0) */ float mixer_hsv[NUM_MIXER_COLORS][3] = { @@ -26124,12 +24908,9 @@ const char *color_mixer_color_tips[] = { gettext_noop("Your color is %1$s %2$s."), gettext_noop("Your color is %1$s %2$s and %3$s %4$s."), gettext_noop("Your color is %1$s %2$s, %3$s %4$s, and %5$s %6$s."), - gettext_noop - ("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, and %7$s %8$s."), - gettext_noop - ("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, %7$s %8$s, and %9$s %10$s."), - gettext_noop - ("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, %7$s %8$s, %9$s %10$s, and %11$s %12$s.") + gettext_noop("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, and %7$s %8$s."), + gettext_noop("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, %7$s %8$s, and %9$s %10$s."), + gettext_noop("Your color is %1$s %2$s, %3$s %4$s, %5$s %6$s, %7$s %8$s, %9$s %10$s, and %11$s %12$s.") }; @@ -26146,6 +24927,7 @@ int mixer_undo_buf[NUM_COLOR_MIX_UNDO_BUFS]; static int do_color_mix(void) { int i, btn_clicked; + #ifndef NO_PROMPT_SHADOWS SDL_Surface *alpha_surf; #endif @@ -26165,6 +24947,7 @@ static int do_color_mix(void) SDL_Surface *backup; SDL_Rect r_final; int old_color_mixer_reset; + val_x = val_y = motioner = 0; valhat_x = valhat_y = hatmotioner = 0; hide_blinking_cursor(); @@ -26179,8 +24962,7 @@ static int do_color_mix(void) backup = SDL_CreateRGBSurface(screen->flags, screen->w, screen->h, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_BlitSurface(screen, NULL, backup, NULL); @@ -26207,9 +24989,8 @@ static int do_color_mix(void) dest.h = w * 2; SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255 - (int) (w / button_scale), - 255 - (int) (w / button_scale), - 255 - (int) (w / button_scale))); + SDL_MapRGB(screen->format, 255 - (int)(w / button_scale), + 255 - (int)(w / button_scale), 255 - (int)(w / button_scale))); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); if (w % 16 == 0) @@ -26224,14 +25005,11 @@ static int do_color_mix(void) r_final.h + 16, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, - screen->format->Amask); + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); if (alpha_surf != NULL) { - SDL_FillRect(alpha_surf, NULL, - SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); + SDL_FillRect(alpha_surf, NULL, SDL_MapRGBA(alpha_surf->format, 0, 0, 0, 64)); for (i = 8; i > 0; i = i - 2) { @@ -26266,16 +25044,14 @@ static int do_color_mix(void) color_example_dest.w = cell_w * 2; color_example_dest.h = cell_h * 2; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 0, 0, 0)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 0, 0, 0)); color_example_dest.x += 2; color_example_dest.y += 2; color_example_dest.w -= 4; color_example_dest.h -= 4; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 255, 255, 255)); color_example_dest.x += 2; color_example_dest.y += 2; @@ -26292,13 +25068,10 @@ static int do_color_mix(void) { SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, - color_hexes[COLOR_MIXER][0], - color_hexes[COLOR_MIXER][1], - color_hexes[COLOR_MIXER][2])); + color_hexes[COLOR_MIXER][0], color_hexes[COLOR_MIXER][1], color_hexes[COLOR_MIXER][2])); } - rgbtohsv(color_hexes[COLOR_MIXER][0], color_hexes[COLOR_MIXER][1], - color_hexes[COLOR_MIXER][2], &h, &s, &v); + rgbtohsv(color_hexes[COLOR_MIXER][0], color_hexes[COLOR_MIXER][1], color_hexes[COLOR_MIXER][2], &h, &s, &v); if (s == 0) { /* Current color is totally greyscale; set hue to "N/A" */ @@ -26347,13 +25120,8 @@ static int do_color_mix(void) dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_CLEAR]; SDL_BlitSurface(img_erase, NULL, screen, &dest); - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_CLEAR] + (img_back->w - - img_mixerlabel_clear->w) / - 2; - dest.y = - color_mix_btn_tops[COLOR_MIXER_BTN_CLEAR] + img_back->h - - img_mixerlabel_clear->h; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_CLEAR] + (img_back->w - img_mixerlabel_clear->w) / 2; + dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_CLEAR] + img_back->h - img_mixerlabel_clear->h; SDL_BlitSurface(img_mixerlabel_clear, NULL, screen, &dest); @@ -26366,12 +25134,8 @@ static int do_color_mix(void) dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_BACK]; SDL_BlitSurface(img_back, NULL, screen, &dest); - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_BACK] + (img_back->w - - img_openlabels_back->w) / 2; - dest.y = - color_mix_btn_tops[COLOR_MIXER_BTN_BACK] + img_back->h - - img_openlabels_back->h; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_BACK] + (img_back->w - img_openlabels_back->w) / 2; + dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_BACK] + img_back->h - img_openlabels_back->h; SDL_BlitSurface(img_openlabels_back, NULL, screen, &dest); /* Show "OK" button */ @@ -26450,8 +25214,7 @@ static int do_color_mix(void) { if (event.button.x >= color_mix_btn_lefts[i] && event.button.x < color_mix_btn_lefts[i] + img_back->w && - event.button.y >= color_mix_btn_tops[i] && - event.button.y < color_mix_btn_tops[i] + img_back->h) + event.button.y >= color_mix_btn_tops[i] && event.button.y < color_mix_btn_tops[i] + img_back->h) { btn_clicked = i; } @@ -26463,9 +25226,7 @@ static int do_color_mix(void) btn_clicked == COLOR_MIXER_BTN_BACK || (btn_clicked == COLOR_MIXER_BTN_UNDO && color_mix_cur_undo != color_mix_oldest_undo) - || (btn_clicked == COLOR_MIXER_BTN_REDO - && color_mix_cur_undo != color_mix_newest_undo) - ) + || (btn_clicked == COLOR_MIXER_BTN_REDO && color_mix_cur_undo != color_mix_newest_undo)) { do_setcursor(cursor_hand); } @@ -26474,8 +25235,7 @@ static int do_color_mix(void) do_setcursor(cursor_arrow); } } - else if (event.type == SDL_MOUSEBUTTONUP - && valid_click(event.button.button)) + else if (event.type == SDL_MOUSEBUTTONUP && valid_click(event.button.button)) { /* Released a click, determine what action to take! */ @@ -26485,8 +25245,7 @@ static int do_color_mix(void) { if (event.button.x >= color_mix_btn_lefts[i] && event.button.x < color_mix_btn_lefts[i] + img_back->w && - event.button.y >= color_mix_btn_tops[i] && - event.button.y < color_mix_btn_tops[i] + img_back->h) + event.button.y >= color_mix_btn_tops[i] && event.button.y < color_mix_btn_tops[i] + img_back->h) { btn_clicked = i; } @@ -26527,11 +25286,9 @@ static int do_color_mix(void) /* Record into undo buffer */ mixer_undo_buf[color_mix_cur_undo] = btn_clicked; - color_mix_cur_undo = - (color_mix_cur_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; + color_mix_cur_undo = (color_mix_cur_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; if (color_mix_cur_undo == color_mix_oldest_undo) - color_mix_oldest_undo = - (color_mix_oldest_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; + color_mix_oldest_undo = (color_mix_oldest_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; color_mix_newest_undo = color_mix_cur_undo; draw_color_mix_undo_redo(); @@ -26541,8 +25298,7 @@ static int do_color_mix(void) hsvtorgb(h, s, v, &new_r, &new_g, &new_b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, new_r, new_g, new_b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, new_r, new_g, new_b)); SDL_UpdateRect(screen, color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); @@ -26571,8 +25327,7 @@ static int do_color_mix(void) color_mixer_reset = 1; /* Wipe undo buffer */ - color_mix_cur_undo = color_mix_oldest_undo = color_mix_newest_undo = - 0; + color_mix_cur_undo = color_mix_oldest_undo = color_mix_newest_undo = 0; draw_color_mix_undo_redo(); /* Clear color usage counts */ @@ -26587,8 +25342,7 @@ static int do_color_mix(void) dest.w = cell_w; dest.h = cell_h; - SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255)); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); draw_color_mixer_blank_example(); @@ -26600,14 +25354,12 @@ static int do_color_mix(void) { eraser_sound = (eraser_sound + 1) % 2; - playsound(screen, 0, SND_ERASER1 + eraser_sound, 0, - SNDPOS_CENTER, SNDDIST_NEAR); + playsound(screen, 0, SND_ERASER1 + eraser_sound, 0, SNDPOS_CENTER, SNDDIST_NEAR); } } #endif } - else if (btn_clicked == COLOR_MIXER_BTN_UNDO - && color_mix_cur_undo != color_mix_oldest_undo) + else if (btn_clicked == COLOR_MIXER_BTN_UNDO && color_mix_cur_undo != color_mix_oldest_undo) { int tot_count; @@ -26629,8 +25381,7 @@ static int do_color_mix(void) hsvtorgb(h, s, v, &new_r, &new_g, &new_b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, new_r, new_g, new_b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, new_r, new_g, new_b)); SDL_UpdateRect(screen, color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); @@ -26648,8 +25399,7 @@ static int do_color_mix(void) dest.w = cell_w; dest.h = cell_h; - SDL_FillRect(screen, &dest, - SDL_MapRGB(screen->format, 255, 255, 255)); + SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 255, 255, 255)); SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); draw_tux_text(TUX_BORED, color_names[COLOR_MIXER], 1); @@ -26658,8 +25408,7 @@ static int do_color_mix(void) playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, SNDDIST_NEAR); draw_color_mix_undo_redo(); } - else if (btn_clicked == COLOR_MIXER_BTN_REDO - && color_mix_cur_undo != color_mix_newest_undo) + else if (btn_clicked == COLOR_MIXER_BTN_REDO && color_mix_cur_undo != color_mix_newest_undo) { /* Redo! */ color_mixer_color_counts[mixer_undo_buf[color_mix_cur_undo]]++; @@ -26668,8 +25417,7 @@ static int do_color_mix(void) hsvtorgb(h, s, v, &new_r, &new_g, &new_b); - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, new_r, new_g, new_b)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, new_r, new_g, new_b)); SDL_UpdateRect(screen, color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); @@ -26687,8 +25435,7 @@ static int do_color_mix(void) SDL_UpdateRect(screen, dest.x, dest.y, dest.w, dest.h); } - color_mix_cur_undo = - (color_mix_cur_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; + color_mix_cur_undo = (color_mix_cur_undo + 1) % NUM_COLOR_MIX_UNDO_BUFS; playsound(screen, 1, SND_CLICK, 1, SNDPOS_CENTER, SNDDIST_NEAR); draw_color_mix_undo_redo(); @@ -26700,20 +25447,17 @@ static int do_color_mix(void) handle_joyaxismotion(event, &motioner, &val_x, &val_y); else if (event.type == SDL_JOYHATMOTION) - handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, - &hatmotioner, &old_hat_ticks); + handle_joyhatmotion(event, oldpos_x, oldpos_y, &valhat_x, &valhat_y, &hatmotioner, &old_hat_ticks); else if (event.type == SDL_JOYBALLMOTION) handle_joyballmotion(event, oldpos_x, oldpos_y); - else if (event.type == SDL_JOYBUTTONDOWN - || event.type == SDL_JOYBUTTONUP) + else if (event.type == SDL_JOYBUTTONDOWN || event.type == SDL_JOYBUTTONUP) handle_joybuttonupdown(event, oldpos_x, oldpos_y); } if (motioner | hatmotioner) - handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, - old_hat_ticks, val_x, val_y, valhat_x, valhat_y); + handle_motioners(oldpos_x, oldpos_y, motioner, hatmotioner, old_hat_ticks, val_x, val_y, valhat_x, valhat_y); SDL_Delay(10); } @@ -26757,8 +25501,7 @@ static void draw_color_mixer_blank_example(void) int w; SDL_Rect dest; - SDL_FillRect(screen, &color_example_dest, - SDL_MapRGB(screen->format, 192, 192, 192)); + SDL_FillRect(screen, &color_example_dest, SDL_MapRGB(screen->format, 192, 192, 192)); for (w = 0; w < color_example_dest.w; w += 4) { @@ -26770,8 +25513,7 @@ static void draw_color_mixer_blank_example(void) SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 128, 128, 128)); } - SDL_UpdateRect(screen, color_example_dest.x, color_example_dest.y, - color_example_dest.w, color_example_dest.h); + SDL_UpdateRect(screen, color_example_dest.x, color_example_dest.y, color_example_dest.w, color_example_dest.h); } @@ -26799,10 +25541,8 @@ static void calc_color_mixer_average(float *out_h, float *out_s, float *out_v) { tot_count_hue += color_mixer_color_counts[i]; - circ_mean_avg_sin += - (sin(mixer_hsv[i][0] * M_PI / 180.0) * color_mixer_color_counts[i]); - circ_mean_avg_cos += - (cos(mixer_hsv[i][0] * M_PI / 180.0) * color_mixer_color_counts[i]); + circ_mean_avg_sin += (sin(mixer_hsv[i][0] * M_PI / 180.0) * color_mixer_color_counts[i]); + circ_mean_avg_cos += (cos(mixer_hsv[i][0] * M_PI / 180.0) * color_mixer_color_counts[i]); } sat += mixer_hsv[i][1] * (color_mixer_color_counts[i]); @@ -26863,9 +25603,7 @@ static void draw_color_mix_undo_redo(void) icon_label_color = img_grey; } - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_UNDO] + (img_back->w - - img_tools[TOOL_UNDO]->w) / 2; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_UNDO] + (img_back->w - img_tools[TOOL_UNDO]->w) / 2; dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_UNDO]; tmp_surf = SDL_DisplayFormatAlpha(img_tools[TOOL_UNDO]); @@ -26873,13 +25611,8 @@ static void draw_color_mix_undo_redo(void) SDL_BlitSurface(tmp_surf, NULL, screen, &dest); SDL_FreeSurface(tmp_surf); - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_UNDO] + (img_back->w - - img_tool_names[TOOL_UNDO]->w) - / 2; - dest.y = - color_mix_btn_tops[COLOR_MIXER_BTN_UNDO] + img_back->h - - img_tool_names[TOOL_UNDO]->h; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_UNDO] + (img_back->w - img_tool_names[TOOL_UNDO]->w) / 2; + dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_UNDO] + img_back->h - img_tool_names[TOOL_UNDO]->h; tmp_surf = SDL_DisplayFormatAlpha(img_tool_names[TOOL_UNDO]); SDL_BlitSurface(icon_label_color, NULL, tmp_surf, NULL); @@ -26887,8 +25620,7 @@ static void draw_color_mix_undo_redo(void) SDL_FreeSurface(tmp_surf); SDL_UpdateRect(screen, color_mix_btn_lefts[COLOR_MIXER_BTN_UNDO], - color_mix_btn_tops[COLOR_MIXER_BTN_UNDO], img_back->w, - img_back->h); + color_mix_btn_tops[COLOR_MIXER_BTN_UNDO], img_back->w, img_back->h); /* Show "Redo" button */ @@ -26907,9 +25639,7 @@ static void draw_color_mix_undo_redo(void) icon_label_color = img_grey; } - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_REDO] + (img_back->w - - img_tools[TOOL_REDO]->w) / 2; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_REDO] + (img_back->w - img_tools[TOOL_REDO]->w) / 2; dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_REDO]; tmp_surf = SDL_DisplayFormatAlpha(img_tools[TOOL_REDO]); @@ -26917,13 +25647,8 @@ static void draw_color_mix_undo_redo(void) SDL_BlitSurface(tmp_surf, NULL, screen, &dest); SDL_FreeSurface(tmp_surf); - dest.x = - color_mix_btn_lefts[COLOR_MIXER_BTN_REDO] + (img_back->w - - img_tool_names[TOOL_REDO]->w) - / 2; - dest.y = - color_mix_btn_tops[COLOR_MIXER_BTN_REDO] + img_back->h - - img_tool_names[TOOL_REDO]->h; + dest.x = color_mix_btn_lefts[COLOR_MIXER_BTN_REDO] + (img_back->w - img_tool_names[TOOL_REDO]->w) / 2; + dest.y = color_mix_btn_tops[COLOR_MIXER_BTN_REDO] + img_back->h - img_tool_names[TOOL_REDO]->h; tmp_surf = SDL_DisplayFormatAlpha(img_tool_names[TOOL_REDO]); SDL_BlitSurface(icon_label_color, NULL, tmp_surf, NULL); @@ -26931,8 +25656,7 @@ static void draw_color_mix_undo_redo(void) SDL_FreeSurface(tmp_surf); SDL_UpdateRect(screen, color_mix_btn_lefts[COLOR_MIXER_BTN_REDO], - color_mix_btn_tops[COLOR_MIXER_BTN_REDO], img_back->w, - img_back->h); + color_mix_btn_tops[COLOR_MIXER_BTN_REDO], img_back->w, img_back->h); } @@ -26944,8 +25668,7 @@ static void draw_color_mixer_tooltip(void) int i, num_colors_used, tot_count; char tip_txt[1024]; char tip_txt_proportions[NUM_MIXER_COLORS][64]; - int used_colors_color[NUM_MIXER_COLORS], - used_colors_amount[NUM_MIXER_COLORS]; + int used_colors_color[NUM_MIXER_COLORS], used_colors_amount[NUM_MIXER_COLORS]; num_colors_used = 0; tot_count = 0; @@ -26967,19 +25690,15 @@ static void draw_color_mixer_tooltip(void) { snprintf(tip_txt, sizeof(tip_txt), gettext(color_mixer_color_tips[0]), /* Color mixer; e.g., "Your color is entirely grey." */ - gettext("entirely"), - gettext(color_mixer_color_names[used_colors_color[0]])); + gettext("entirely"), gettext(color_mixer_color_names[used_colors_color[0]])); } else { snprintf(tip_txt_proportions[0], sizeof(tip_txt_proportions[0]), - "%1$s (%2$d/%3$d)", - gettext("entirely"), - used_colors_amount[0], used_colors_amount[0]); + "%1$s (%2$d/%3$d)", gettext("entirely"), used_colors_amount[0], used_colors_amount[0]); snprintf(tip_txt, sizeof(tip_txt), gettext(color_mixer_color_tips[0]), - tip_txt_proportions[0], - gettext(color_mixer_color_names[used_colors_color[0]])); + tip_txt_proportions[0], gettext(color_mixer_color_names[used_colors_color[0]])); } } else @@ -26991,8 +25710,7 @@ static void draw_color_mixer_tooltip(void) best_factor = 0; for (factor = 2; factor <= used_colors_amount[i]; factor++) { - if ((used_colors_amount[i] % factor) == 0 - && (tot_count % factor) == 0) + if ((used_colors_amount[i] % factor) == 0 && (tot_count % factor) == 0) best_factor = factor; } @@ -27001,13 +25719,11 @@ static void draw_color_mixer_tooltip(void) snprintf(tip_txt_proportions[i], sizeof(tip_txt_proportions[i]), "%d/%d (%d/%d)", used_colors_amount[i], tot_count, - (int) (used_colors_amount[i] / best_factor), - (int) (tot_count / best_factor)); + (int)(used_colors_amount[i] / best_factor), (int)(tot_count / best_factor)); } else { - snprintf(tip_txt_proportions[i], sizeof(tip_txt_proportions[i]), - "%d/%d", used_colors_amount[i], tot_count); + snprintf(tip_txt_proportions[i], sizeof(tip_txt_proportions[i]), "%d/%d", used_colors_amount[i], tot_count); } } @@ -27018,8 +25734,7 @@ static void draw_color_mixer_tooltip(void) gettext(color_mixer_color_tips[num_colors_used - 1]), tip_txt_proportions[0], gettext(color_mixer_color_names[used_colors_color[0]]), - tip_txt_proportions[1], - gettext(color_mixer_color_names[used_colors_color[1]])); + tip_txt_proportions[1], gettext(color_mixer_color_names[used_colors_color[1]])); } else if (num_colors_used == 3) { @@ -27029,8 +25744,7 @@ static void draw_color_mixer_tooltip(void) gettext(color_mixer_color_names[used_colors_color[0]]), tip_txt_proportions[1], gettext(color_mixer_color_names[used_colors_color[1]]), - tip_txt_proportions[2], - gettext(color_mixer_color_names[used_colors_color[2]])); + tip_txt_proportions[2], gettext(color_mixer_color_names[used_colors_color[2]])); } else if (num_colors_used == 4) { @@ -27042,8 +25756,7 @@ static void draw_color_mixer_tooltip(void) gettext(color_mixer_color_names[used_colors_color[1]]), tip_txt_proportions[2], gettext(color_mixer_color_names[used_colors_color[2]]), - tip_txt_proportions[3], - gettext(color_mixer_color_names[used_colors_color[3]])); + tip_txt_proportions[3], gettext(color_mixer_color_names[used_colors_color[3]])); } else if (num_colors_used == 5) { @@ -27057,8 +25770,7 @@ static void draw_color_mixer_tooltip(void) gettext(color_mixer_color_names[used_colors_color[2]]), tip_txt_proportions[3], gettext(color_mixer_color_names[used_colors_color[3]]), - tip_txt_proportions[4], - gettext(color_mixer_color_names[used_colors_color[4]])); + tip_txt_proportions[4], gettext(color_mixer_color_names[used_colors_color[4]])); } else if (num_colors_used == 6) { @@ -27074,8 +25786,7 @@ static void draw_color_mixer_tooltip(void) gettext(color_mixer_color_names[used_colors_color[3]]), tip_txt_proportions[4], gettext(color_mixer_color_names[used_colors_color[4]]), - tip_txt_proportions[5], - gettext(color_mixer_color_names[used_colors_color[5]])); + tip_txt_proportions[5], gettext(color_mixer_color_names[used_colors_color[5]])); } } @@ -27089,13 +25800,13 @@ static void draw_color_mixer_tooltip(void) * @param int the_color - the color within the palette (e.g., COLOR_PICKER) (its RGB values will be grabbed via global color_hexes[], and the new button will be rendered into the appropriate img_color_btns[]) * @param SDL_Surface * decoration - a decoration bitmap to be applied to the button (or NULL if none) (e.g., the color picker rainbow that appears around the color picker button's paintwell) */ -static void render_color_button(int the_color, SDL_Surface * decoration, - SDL_Surface * icon) +static void render_color_button(int the_color, SDL_Surface * decoration, SDL_Surface * icon) { SDL_Surface *tmp_btn_up, *tmp_btn_down; SDL_Rect dest; double rh, gh, bh; int x, y; + Uint32(*getpixel_tmp_btn_up) (SDL_Surface *, int, int); Uint32(*getpixel_tmp_btn_down) (SDL_Surface *, int, int); Uint32(*getpixel_img_paintwell) (SDL_Surface *, int, int); @@ -27122,34 +25833,27 @@ static void render_color_button(int the_color, SDL_Surface * decoration, double ru, gu, bu, rd, gd, bd, aa; Uint8 a, r, g, b; - SDL_GetRGB(getpixel_tmp_btn_up(tmp_btn_up, x, y), tmp_btn_up->format, - &r, &g, &b); + SDL_GetRGB(getpixel_tmp_btn_up(tmp_btn_up, x, y), tmp_btn_up->format, &r, &g, &b); ru = sRGB_to_linear_table[r]; gu = sRGB_to_linear_table[g]; bu = sRGB_to_linear_table[b]; - SDL_GetRGB(getpixel_tmp_btn_down(tmp_btn_down, x, y), - tmp_btn_down->format, &r, &g, &b); + SDL_GetRGB(getpixel_tmp_btn_down(tmp_btn_down, x, y), tmp_btn_down->format, &r, &g, &b); rd = sRGB_to_linear_table[r]; gd = sRGB_to_linear_table[g]; bd = sRGB_to_linear_table[b]; - SDL_GetRGBA(getpixel_img_paintwell(img_paintwell, x, y), - img_paintwell->format, &r, &g, &b, &a); + SDL_GetRGBA(getpixel_img_paintwell(img_paintwell, x, y), img_paintwell->format, &r, &g, &b, &a); aa = a / 255.0; if (decoration != NULL) { putpixels[img_color_btns[the_color]->format->BytesPerPixel] - (img_color_btns[the_color], x, y, - getpixels[decoration->format->BytesPerPixel] (decoration, x, y)); - putpixels[img_color_btns[the_color + NUM_COLORS]->format-> - BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, - y, - getpixels[decoration->format-> - BytesPerPixel] (decoration, x, - y)); + (img_color_btns[the_color], x, y, getpixels[decoration->format->BytesPerPixel] (decoration, x, y)); + putpixels[img_color_btns[the_color + NUM_COLORS]-> + format->BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, y, + getpixels[decoration->format->BytesPerPixel] (decoration, x, y)); } if (a == 255) @@ -27158,21 +25862,14 @@ static void render_color_button(int the_color, SDL_Surface * decoration, (img_color_btns[the_color], x, y, SDL_MapRGB(img_color_btns[the_color]->format, linear_to_sRGB(rh * aa + ru * (1.0 - aa)), - linear_to_sRGB(gh * aa + gu * (1.0 - aa)), - linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); + linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); - putpixels[img_color_btns[the_color + NUM_COLORS]->format-> - BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, - y, - SDL_MapRGB(img_color_btns - [the_color + NUM_COLORS]->format, - linear_to_sRGB(rh * aa + - rd * (1.0 - aa)), - linear_to_sRGB(gh * aa + - gd * (1.0 - aa)), - linear_to_sRGB(bh * aa + - bd * (1.0 - - aa)))); + putpixels[img_color_btns[the_color + NUM_COLORS]-> + format->BytesPerPixel] (img_color_btns[the_color + NUM_COLORS], x, y, + SDL_MapRGB(img_color_btns[the_color + NUM_COLORS]->format, + linear_to_sRGB(rh * aa + rd * (1.0 - aa)), + linear_to_sRGB(gh * aa + gd * (1.0 - aa)), + linear_to_sRGB(bh * aa + bd * (1.0 - aa)))); } } } @@ -27194,8 +25891,7 @@ static void render_color_button(int the_color, SDL_Surface * decoration, dest.x = (img_color_btns[the_color + NUM_COLORS]->w - icon->w) / 2; dest.y = (img_color_btns[the_color + NUM_COLORS]->h - icon->h) / 2; - SDL_BlitSurface(icon, NULL, img_color_btns[the_color + NUM_COLORS], - &dest); + SDL_BlitSurface(icon, NULL, img_color_btns[the_color + NUM_COLORS], &dest); } } @@ -27210,16 +25906,22 @@ static void handle_color_changed(void) { render_brush(); - if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) { + if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) + { do_render_cur_text(0); - } else if (cur_tool == TOOL_MAGIC) { + } + else if (cur_tool == TOOL_MAGIC) + { magic_set_color(); - } else if (cur_tool == TOOL_STAMP) { + } + else if (cur_tool == TOOL_STAMP) + { clear_cached_stamp(); } } -static void magic_set_color(void) { +static void magic_set_color(void) +{ int undo_ctr; SDL_Surface *last; SDL_Rect update_rect; @@ -27236,20 +25938,17 @@ static void magic_set_color(void) { last = undo_bufs[undo_ctr]; - magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx]. - set_color(magic_api_struct, - magics[magic_group][cur_magic[magic_group]].idx, - canvas, - last, - color_hexes[cur_color][0], - color_hexes[cur_color][1], - color_hexes[cur_color][2], - &update_rect); + magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].set_color(magic_api_struct, + magics[magic_group][cur_magic + [magic_group]].idx, + canvas, last, color_hexes[cur_color][0], + color_hexes[cur_color][1], + color_hexes[cur_color][2], + &update_rect); - if (update_rect.w > 0 && update_rect.h > 0) { - update_canvas(update_rect.x, update_rect.y, - update_rect.x + update_rect.w, - update_rect.y + update_rect.h); + if (update_rect.w > 0 && update_rect.h > 0) + { + update_canvas(update_rect.x, update_rect.y, update_rect.x + update_rect.w, update_rect.y + update_rect.h); } } @@ -27260,7 +25959,8 @@ static void magic_set_color(void) { * We expect that `magics[magic_group][cur_magic[magic_group]].size` * has been set prior to calling this. */ -static void magic_set_size() { +static void magic_set_size() +{ int undo_ctr; SDL_Surface *last; SDL_Rect update_rect; @@ -27277,19 +25977,22 @@ static void magic_set_size() { last = undo_bufs[undo_ctr]; - magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx]. - set_size(magic_api_struct, - magics[magic_group][cur_magic[magic_group]].idx, - magics[magic_group][cur_magic[magic_group]].mode, - canvas, - last, - magics[magic_group][cur_magic[magic_group]].size[magic_modeint(magics[magic_group][cur_magic[magic_group]].mode)], - &update_rect); + magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].set_size(magic_api_struct, + magics[magic_group][cur_magic + [magic_group]].idx, + magics[magic_group][cur_magic + [magic_group]].mode, + canvas, last, + magics[magic_group][cur_magic + [magic_group]]. + size[magic_modeint + (magics[magic_group] + [cur_magic[magic_group]].mode)], + &update_rect); - if (update_rect.w > 0 && update_rect.h > 0) { - update_canvas(update_rect.x, update_rect.y, - update_rect.x + update_rect.w, - update_rect.y + update_rect.h); + if (update_rect.w > 0 && update_rect.h > 0) + { + update_canvas(update_rect.x, update_rect.y, update_rect.x + update_rect.w, update_rect.y + update_rect.h); } } @@ -27341,9 +26044,7 @@ static void magic_switchout(SDL_Surface * last) cur = cur_magic[magic_group]; magic_funcs[magics[grp][cur].handle_idx].switchout(magic_api_struct, - magics[grp][cur].idx, - magics[grp][cur].mode, - canvas, last); + magics[grp][cur].idx, magics[grp][cur].mode, canvas, last); update_canvas(0, 0, canvas->w, canvas->h); if (was_clicking && magics[grp][cur].mode == MODE_PAINT_WITH_PREVIEW) @@ -27372,9 +26073,7 @@ static void magic_switchin(SDL_Surface * last) cur = cur_magic[magic_group]; magic_funcs[magics[grp][cur].handle_idx].switchin(magic_api_struct, - magics[grp][cur].idx, - magics[grp][cur].mode, - canvas, last); + magics[grp][cur].idx, magics[grp][cur].mode, canvas, last); /* In case the Magic tool's switchin() called update_progress_bar(), let's put the old Tux text back: */ @@ -27390,8 +26089,7 @@ static void magic_switchin(SDL_Surface * last) */ static int magic_modeint(int mode) { - if (mode == MODE_PAINT || mode == MODE_ONECLICK - || mode == MODE_PAINT_WITH_PREVIEW) + if (mode == MODE_PAINT || mode == MODE_ONECLICK || mode == MODE_PAINT_WITH_PREVIEW) return 0; else if (mode == MODE_FULLSCREEN) return 1; @@ -27402,8 +26100,7 @@ static int magic_modeint(int mode) /** * FIXME */ -static void add_label_node(int w, int h, Uint16 x, Uint16 y, - SDL_Surface * label_node_surface) +static void add_label_node(int w, int h, Uint16 x, Uint16 y, SDL_Surface * label_node_surface) { struct label_node *new_node = malloc(sizeof(struct label_node)); struct label_node *aux_node; @@ -27481,8 +26178,7 @@ static void add_label_node(int w, int h, Uint16 x, Uint16 y, /** * FIXME */ -static struct label_node *search_label_list(struct label_node **ref_head, - Uint16 x, Uint16 y, int hover) +static struct label_node *search_label_list(struct label_node **ref_head, Uint16 x, Uint16 y, int hover) { struct label_node *current_node; struct label_node *tmp_node = NULL; @@ -27563,24 +26259,26 @@ static struct label_node *search_label_list(struct label_node **ref_head, for (i = 0; i < 48; i++) { SDL_GetRGBA(getpixels[img_paintwell->format->BytesPerPixel] - (img_paintwell, i, j), img_paintwell->format, &r, &g, - &b, &a); + (img_paintwell, i, j), img_paintwell->format, &r, &g, &b, &a); if (a == 255) { putpixels[img_color_btns[COLOR_PICKER]->format->BytesPerPixel] (img_color_btns[COLOR_PICKER], i, j, SDL_MapRGB(img_color_btns[COLOR_PICKER]->format, - tmp_node->save_color.r, tmp_node->save_color.g, - tmp_node->save_color.b)); - putpixels[img_color_btns[COLOR_PICKER + NUM_COLORS]->format-> - BytesPerPixel] (img_color_btns[COLOR_PICKER + - NUM_COLORS], i, j, - SDL_MapRGB(img_color_btns - [COLOR_PICKER + - NUM_COLORS]->format, - tmp_node->save_color.r, - tmp_node->save_color.g, - tmp_node->save_color.b)); + tmp_node->save_color.r, tmp_node->save_color.g, tmp_node->save_color.b)); + putpixels[img_color_btns[COLOR_PICKER + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[COLOR_PICKER + + NUM_COLORS], + i, j, + SDL_MapRGB(img_color_btns + [COLOR_PICKER + + NUM_COLORS]-> + format, + tmp_node-> + save_color.r, + tmp_node-> + save_color.g, + tmp_node-> + save_color.b)); } } } @@ -27642,8 +26340,7 @@ static void rec_undo_label(void) text_undo[cur_undo] = 0; /* Have we cycled around NUM_UNDO_BUFS? */ - if (current_label_node != NULL - && current_label_node->save_undoid == (cur_undo + 1) % NUM_UNDO_BUFS) + if (current_label_node != NULL && current_label_node->save_undoid == (cur_undo + 1) % NUM_UNDO_BUFS) current_label_node->save_undoid = 255; } } @@ -27685,8 +26382,7 @@ static void do_redo_label_node() if (first_label_node_in_redo_stack->save_undoid == cur_undo) { current_label_node = first_label_node_in_redo_stack; - first_label_node_in_redo_stack = - current_label_node->next_to_up_label_node; + first_label_node_in_redo_stack = current_label_node->next_to_up_label_node; if (start_label_node == NULL) start_label_node = current_label_node; @@ -27777,8 +26473,7 @@ static void simply_render_node(struct label_node *node) myblit(node->label_node_surface, &src, label, &dest); - update_canvas(dest.x, dest.y, dest.x + node->label_node_surface->w, - dest.y + node->label_node_surface->h); + update_canvas(dest.x, dest.y, dest.x + node->label_node_surface->w, dest.y + node->label_node_surface->h); /* Setting the sizes correctly */ node->save_width = node->label_node_surface->w; @@ -27823,8 +26518,7 @@ static void derender_node( __attribute__((unused)) r_tmp_derender.x = 0; r_tmp_derender.y = 0; - SDL_FillRect(label, &r_tmp_derender, - SDL_MapRGBA(label->format, 0, 0, 0, 0)); + SDL_FillRect(label, &r_tmp_derender, SDL_MapRGBA(label->format, 0, 0, 0, 0)); render_all_nodes_starting_at(&start_label_node); } @@ -27856,8 +26550,7 @@ static void delete_label_list(struct label_node **ref_head) */ /* A custom bliter that allows to put two transparent layers toghether without having to deal with colorkeys or SDL_SRCALPHA I am always reinventing the wheel. Hope this one is not squared. Pere */ -static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, - SDL_Surface * dest_surf, SDL_Rect * dest_rect) +static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, SDL_Surface * dest_surf, SDL_Rect * dest_rect) { int x, y; Uint8 src_r, src_g, src_b, src_a; @@ -27867,18 +26560,14 @@ static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, for (y = src_rect->y; y < src_rect->h + src_rect->y; y++) { SDL_GetRGBA(getpixels[src_surf->format->BytesPerPixel] - (src_surf, x - src_rect->x, y - src_rect->y), - src_surf->format, &src_r, &src_g, &src_b, &src_a); + (src_surf, x - src_rect->x, y - src_rect->y), src_surf->format, &src_r, &src_g, &src_b, &src_a); if (src_a != SDL_ALPHA_TRANSPARENT) { if (src_a == SDL_ALPHA_OPAQUE) putpixels[dest_surf->format->BytesPerPixel] (dest_surf, x + dest_rect->x, y + dest_rect->y, - SDL_MapRGBA - (dest_surf->format, - src_r, src_g, src_b, - src_a)); + SDL_MapRGBA(dest_surf->format, src_r, src_g, src_b, src_a)); else { SDL_GetRGBA(getpixels[dest_surf->format->BytesPerPixel] @@ -27888,29 +26577,18 @@ static void myblit(SDL_Surface * src_surf, SDL_Rect * src_rect, putpixels[dest_surf->format->BytesPerPixel] (dest_surf, x + dest_rect->x, y + dest_rect->y, - SDL_MapRGBA - (dest_surf->format, - src_r, src_g, src_b, - src_a)); + SDL_MapRGBA(dest_surf->format, src_r, src_g, src_b, src_a)); else { - dest_r = - src_r * src_a / 255 + dest_r * dest_a * (255 - - src_a) / 255 / 255; - dest_g = - src_g * src_a / 255 + dest_g * dest_a * (255 - - src_a) / 255 / 255; - dest_b = - src_b * src_a / 255 + dest_b * dest_a * (255 - - src_a) / 255 / 255; + dest_r = src_r * src_a / 255 + dest_r * dest_a * (255 - src_a) / 255 / 255; + dest_g = src_g * src_a / 255 + dest_g * dest_a * (255 - src_a) / 255 / 255; + dest_b = src_b * src_a / 255 + dest_b * dest_a * (255 - src_a) / 255 / 255; dest_a = src_a + dest_a * (255 - src_a) / 255; putpixels[dest_surf->format->BytesPerPixel] (dest_surf, x + dest_rect->x, y + dest_rect->y, SDL_MapRGBA - (dest_surf->format, - dest_r, dest_g, - dest_b, dest_a)); + (dest_surf->format, dest_r, dest_g, dest_b, dest_a)); } } } @@ -27944,6 +26622,7 @@ static void load_info_about_label_surface(FILE * lfi) int tmp_fscanf_return; char *tmp_fgets_return; Uint8 a; + #ifdef WIN32 wchar_t *wtmpstr; #endif @@ -27971,8 +26650,7 @@ static void load_info_about_label_surface(FILE * lfi) if (list_ctr <= 0) { - fprintf(stderr, "Unexpected! Count of label notes is <= 0 (%d)!\n", - list_ctr); + fprintf(stderr, "Unexpected! Count of label notes is <= 0 (%d)!\n", list_ctr); fclose(lfi); return; } @@ -27982,12 +26660,11 @@ static void load_info_about_label_surface(FILE * lfi) larger UI button size, etc. */ tmp_fscanf_return = fscanf(lfi, "%d\n", &tmp_scale_w); tmp_fscanf_return = fscanf(lfi, "%d\n\n", &tmp_scale_h); - (void) tmp_fscanf_return; + (void)tmp_fscanf_return; if (tmp_scale_w <= 0 || tmp_scale_h <= 0) { - fprintf(stderr, "Unexpected! Saved canvas dimensions %d x %d!\n", - tmp_scale_w, tmp_scale_h); + fprintf(stderr, "Unexpected! Saved canvas dimensions %d x %d!\n", tmp_scale_w, tmp_scale_h); fclose(lfi); return; } @@ -27997,12 +26674,12 @@ static void load_info_about_label_surface(FILE * lfi) old_height = tmp_scale_h; new_width = r_canvas.w; new_height = r_canvas.h; - new_ratio = (float) new_width / new_height; - old_ratio = (float) old_width / old_height; + new_ratio = (float)new_width / new_height; + old_ratio = (float)old_width / old_height; if (new_ratio < old_ratio) - new_to_old_ratio = (float) new_width / old_width; + new_to_old_ratio = (float)new_width / old_width; else - new_to_old_ratio = (float) new_height / old_height; + new_to_old_ratio = (float)new_height / old_height; #ifdef WIN32 wtmpstr = malloc(1024); @@ -28021,8 +26698,7 @@ static void load_info_about_label_surface(FILE * lfi) if (new_node->save_texttool_len >= 1024) { - fprintf(stderr, "Unexpected! Saved text length is >= 1024 (%u!)\n", - new_node->save_texttool_len); + fprintf(stderr, "Unexpected! Saved text length is >= 1024 (%u!)\n", new_node->save_texttool_len); free(new_node); #ifdef WIN32 free(wtmpstr); @@ -28042,6 +26718,7 @@ static void load_info_about_label_surface(FILE * lfi) new_node->save_texttool_str[l] = L'\0'; #elif defined(__ANDROID__) wchar_t tmp_char; + for (l = 0; l < new_node->save_texttool_len; l++) { fscanf(lfi, "%d ", &tmp_char); @@ -28050,8 +26727,7 @@ static void load_info_about_label_surface(FILE * lfi) fscanf(lfi, "\n"); #else /* Using fancy "%[]" operator to scan until the end of a line */ - tmp_fscanf_return = - fscanf(lfi, "%l[^\n]\n", new_node->save_texttool_str); + tmp_fscanf_return = fscanf(lfi, "%l[^\n]\n", new_node->save_texttool_str); #endif DEBUG_PRINTF("Read: \"%ls\"\n", new_node->save_texttool_str); @@ -28068,7 +26744,7 @@ static void load_info_about_label_surface(FILE * lfi) tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_width); tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_height); tmp_fscanf_return = fscanf(lfi, "%d\n", &tmp_pos); - old_pos = (int) tmp_pos; + old_pos = (int)tmp_pos; if (new_ratio < old_ratio) { @@ -28076,34 +26752,28 @@ static void load_info_about_label_surface(FILE * lfi) tmp_pos = new_pos; new_node->save_x = tmp_pos; tmp_fscanf_return = fscanf(lfi, "%d\n", &tmp_pos); - old_pos = (int) tmp_pos; - new_pos = - old_pos * new_to_old_ratio + (new_height - - old_height * new_to_old_ratio) / 2; + old_pos = (int)tmp_pos; + new_pos = old_pos * new_to_old_ratio + (new_height - old_height * new_to_old_ratio) / 2; tmp_pos = new_pos; new_node->save_y = tmp_pos; } else { - new_pos = - (old_pos * new_to_old_ratio) + (new_width - - old_width * new_to_old_ratio) / 2; + new_pos = (old_pos * new_to_old_ratio) + (new_width - old_width * new_to_old_ratio) / 2; tmp_pos = new_pos; new_node->save_x = tmp_pos; tmp_fscanf_return = fscanf(lfi, "%d\n", &tmp_pos); - old_pos = (int) tmp_pos; + old_pos = (int)tmp_pos; new_pos = (old_pos * new_to_old_ratio); tmp_pos = new_pos; new_node->save_y = tmp_pos; } - DEBUG_PRINTF("Original label size %dx%d\n", new_node->save_width, - new_node->save_height); + DEBUG_PRINTF("Original label size %dx%d\n", new_node->save_width, new_node->save_height); if (new_node->save_width > 8192 || new_node->save_height > 8192) { - fprintf(stderr, "Unexpected! Save dimensions are (%u x %u!)\n", - new_node->save_width, new_node->save_height); + fprintf(stderr, "Unexpected! Save dimensions are (%u x %u!)\n", new_node->save_width, new_node->save_height); free(new_node); free(tmpstr); #ifdef WIN32 @@ -28120,7 +26790,7 @@ static void load_info_about_label_surface(FILE * lfi) new_node->save_font_type = malloc(64); tmp_fgets_return = fgets(new_node->save_font_type, 64, lfi); - (void) tmp_fgets_return; + (void)tmp_fgets_return; /* Read the label's state (italic &/or bold), and size */ tmp_fscanf_return = fscanf(lfi, "%d\n", &new_node->save_text_state); @@ -28135,39 +26805,35 @@ static void load_info_about_label_surface(FILE * lfi) new_node->save_height, screen->format->BitsPerPixel, screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, - TPAINT_AMASK); + screen->format->Gmask, screen->format->Bmask, TPAINT_AMASK); SDL_LockSurface(label_node_surface); for (x = 0; x < new_node->save_width; x++) for (y = 0; y < new_node->save_height; y++) { a = fgetc(lfi); - putpixels[label_node_surface->format-> - BytesPerPixel] (label_node_surface, x, y, - SDL_MapRGBA(label_node_surface->format, - new_node->save_color.r, - new_node->save_color.g, - new_node->save_color.b, a)); + putpixels[label_node_surface->format->BytesPerPixel] (label_node_surface, x, y, + SDL_MapRGBA(label_node_surface->format, + new_node->save_color.r, + new_node->save_color.g, + new_node->save_color.b, a)); } SDL_UnlockSurface(label_node_surface); /* Set the label's size, in proportion to any canvas size differences */ - new_text_size = (float) new_node->save_text_size * new_to_old_ratio; + new_text_size = (float)new_node->save_text_size * new_to_old_ratio; /* Scale the backbuffer, in proportion... */ label_node_surface_aux = - zoom(label_node_surface, label_node_surface->w * new_to_old_ratio, - label_node_surface->h * new_to_old_ratio); + zoom(label_node_surface, label_node_surface->w * new_to_old_ratio, label_node_surface->h * new_to_old_ratio); SDL_FreeSurface(label_node_surface); new_node->label_node_surface = label_node_surface_aux; new_node->label_node_surface->refcount++; SDL_FreeSurface(label_node_surface_aux); - if ((unsigned) new_text_size > MAX_TEXT_SIZE) /* Here we reach the limits when scaling the font size */ + if ((unsigned)new_text_size > MAX_TEXT_SIZE) /* Here we reach the limits when scaling the font size */ new_node->save_text_size = MAX_TEXT_SIZE; - else if ((unsigned) new_text_size > MIN_TEXT_SIZE) + else if ((unsigned)new_text_size > MIN_TEXT_SIZE) new_node->save_text_size = floor(new_text_size + 0.5); else new_node->save_text_size = MIN_TEXT_SIZE; @@ -28247,11 +26913,9 @@ static void set_label_fonts() node->save_cur_font = i; break; } - else if (strstr(ttffont, node->save_font_type) - || strstr(node->save_font_type, ttffont)) + else if (strstr(ttffont, node->save_font_type) || strstr(node->save_font_type, ttffont)) { - DEBUG_PRINTF("setting %s as replacement", - TTF_FontFaceFamilyName(getfonthandle(i)->ttf_font)); + DEBUG_PRINTF("setting %s as replacement", TTF_FontFaceFamilyName(getfonthandle(i)->ttf_font)); node->save_cur_font = i; } } @@ -28278,16 +26942,13 @@ static void tmp_apply_uncommited_text() if (cur_tool == TOOL_TEXT || (old_tool == TOOL_TEXT && (cur_tool == TOOL_PRINT || - cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN - || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) + cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) { canvas_back = SDL_CreateRGBSurface(canvas->flags, canvas->w, canvas->h, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0); SDL_BlitSurface(canvas, NULL, canvas_back, NULL); do_render_cur_text(1); } @@ -28295,8 +26956,7 @@ static void tmp_apply_uncommited_text() else if (cur_tool == TOOL_LABEL || (old_tool == TOOL_LABEL && (cur_tool == TOOL_PRINT || - cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN - || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) + cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) { do_render_cur_text(1); current_label_node->save_undoid = 253; @@ -28305,8 +26965,7 @@ static void tmp_apply_uncommited_text() else if ((cur_tool == TOOL_LABEL && label_node_to_edit) || ((old_tool == TOOL_LABEL && label_node_to_edit) && (cur_tool == TOOL_PRINT || - cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN - || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) + cur_tool == TOOL_SAVE || cur_tool == TOOL_OPEN || cur_tool == TOOL_NEW || cur_tool == TOOL_QUIT))) { add_label_node(0, 0, 0, 0, NULL); current_label_node->is_enabled = FALSE; @@ -28329,8 +26988,7 @@ static void undo_tmp_applied_text() (cur_tool == TOOL_PRINT && old_tool == TOOL_TEXT) || (cur_tool == TOOL_SAVE && old_tool == TOOL_TEXT) || (cur_tool == TOOL_OPEN && old_tool == TOOL_TEXT) || - (cur_tool == TOOL_NEW && old_tool == TOOL_TEXT) - || (cur_tool == TOOL_QUIT && old_tool == TOOL_TEXT)) + (cur_tool == TOOL_NEW && old_tool == TOOL_TEXT) || (cur_tool == TOOL_QUIT && old_tool == TOOL_TEXT)) { SDL_BlitSurface(canvas_back, NULL, canvas, NULL); SDL_FreeSurface(canvas_back); @@ -28345,8 +27003,7 @@ static void undo_tmp_applied_text() if (current_label_node == NULL) start_label_node = NULL; else - current_label_node->next_to_up_label_node = - first_label_node_in_redo_stack; + current_label_node->next_to_up_label_node = first_label_node_in_redo_stack; derender_node(&aux_label_node); delete_label_list(&aux_label_node); @@ -28382,9 +27039,7 @@ static void highlight_label_nodes() rect.w = aux_node->save_width; rect.h = aux_node->save_height; - SDL_FillRect(screen, &rect, - SDL_MapRGBA(screen->format, 0, 0, 0, - SDL_ALPHA_TRANSPARENT)); + SDL_FillRect(screen, &rect, SDL_MapRGBA(screen->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT)); for (j = 2; j < aux_node->save_height / 4; j++) { @@ -28399,8 +27054,7 @@ static void highlight_label_nodes() SDL_MapRGBA(screen->format, 4 * j * 200 / aux_node->save_height, 4 * j * 200 / aux_node->save_height, - 4 * j * 200 / aux_node->save_height, - SDL_ALPHA_OPAQUE)); + 4 * j * 200 / aux_node->save_height, SDL_ALPHA_OPAQUE)); SDL_BlitSurface(aux_node->label_node_surface, NULL, screen, &rect); } @@ -28417,8 +27071,7 @@ static void highlight_label_nodes() rect.y = aux_node->save_y; rect.w = aux_node->save_width; rect.h = aux_node->save_height; - SDL_FillRect(screen, &rect, - SDL_MapRGBA(screen->format, 255, 0, 0, SDL_ALPHA_OPAQUE)); + SDL_FillRect(screen, &rect, SDL_MapRGBA(screen->format, 255, 0, 0, SDL_ALPHA_OPAQUE)); for (j = 2; j < aux_node->save_height / 4; j++) { @@ -28429,10 +27082,7 @@ static void highlight_label_nodes() break; rect1.h = rect.h - 2 * j; SDL_FillRect(screen, - &rect1, - SDL_MapRGBA(screen->format, 255, - 4 * j * 225 / aux_node->save_height, 0, - SDL_ALPHA_OPAQUE)); + &rect1, SDL_MapRGBA(screen->format, 255, 4 * j * 225 / aux_node->save_height, 0, SDL_ALPHA_OPAQUE)); SDL_BlitSurface(aux_node->label_node_surface, NULL, screen, &rect); } @@ -28462,8 +27112,7 @@ static void cycle_highlighted_label_node() } else { - while (aux_node->is_enabled == FALSE - && aux_node != highlighted_label_node) + while (aux_node->is_enabled == FALSE && aux_node != highlighted_label_node) { aux_node = aux_node->next_to_down_label_node; if (aux_node == NULL) @@ -28515,8 +27164,7 @@ int chunk_is_valid(const char *chunk_name, png_unknown_chunk unknown) 'x' == unknown.data[2] && 'p' == unknown.data[3] && 'a' == unknown.data[4] && - 'i' == unknown.data[5] && 'n' == unknown.data[6] - && 't' == unknown.data[7] && '\n' == unknown.data[8]) + 'i' == unknown.data[5] && 'n' == unknown.data[6] && 't' == unknown.data[7] && '\n' == unknown.data[8]) { /* Passed the first test, now checking if there are at least 4 fields in the first 50 bytes of the chunk data */ @@ -28534,8 +27182,7 @@ int chunk_is_valid(const char *chunk_name, png_unknown_chunk unknown) { /* Last check, see if the sizes match */ control = malloc(50); softwr = malloc(50); - sscanf((char *) unknown.data, "%s\n%s\n%d\n%d\n", control, softwr, - &unc_size, &comp); + sscanf((char *)unknown.data, "%s\n%s\n%d\n%d\n", control, softwr, &unc_size, &comp); free(control); free(softwr); if (count + comp + 1 == unknown.size) @@ -28556,8 +27203,7 @@ int chunk_is_valid(const char *chunk_name, png_unknown_chunk unknown) (unknown.data[count] == '4') || (unknown.data[count] == '5') || (unknown.data[count] == '6') || - (unknown.data[count] == '7') || (unknown.data[count] == '8') - || (unknown.data[count] == '9'))) + (unknown.data[count] == '7') || (unknown.data[count] == '8') || (unknown.data[count] == '9'))) return (FALSE); new_field = 0; @@ -28573,8 +27219,7 @@ int chunk_is_valid(const char *chunk_name, png_unknown_chunk unknown) * FIXME */ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr, - png_infop info_ptr, const char *chunk_name, - png_unknown_chunk unknown, int *unc_size) + png_infop info_ptr, const char *chunk_name, png_unknown_chunk unknown, int *unc_size) { unsigned int i; @@ -28586,8 +27231,7 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr, control = malloc(50); softwr = malloc(50); - sscanf((char *) unknown.data, "%s\n%s\n%d\n%d\n", control, softwr, unc_size, - &comp); + sscanf((char *)unknown.data, "%s\n%s\n%d\n%d\n", control, softwr, unc_size, &comp); free(control); free(softwr); comp_buff = malloc(comp * sizeof(Bytef)); @@ -28658,16 +27302,14 @@ Bytef *get_chunk_data(FILE * fp, char *fname, png_structp png_ptr, if (unc_err != Z_STREAM_END) { - fprintf(stderr, "\n error %d, unc %d, comp %d\n", unc_err, *unc_size, - comp); + fprintf(stderr, "\n error %d, unc %d, comp %d\n", unc_err, *unc_size, comp); fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); free(comp_buff); free(unc_buff); fprintf(stderr, - "Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", - fname, chunk_name); + "Can't recover the embedded data in %s, error in uncompressing data from %s\n\n", fname, chunk_name); draw_tux_text(TUX_OOPS, strerror(errno), 0); return (NULL); } @@ -28747,14 +27389,13 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) ww = png_get_image_width(png_ptr, info_ptr); hh = png_get_image_height(png_ptr, info_ptr); - num_unknowns = (int) png_get_unknown_chunks(png_ptr, info_ptr, &unknowns); + num_unknowns = (int)png_get_unknown_chunks(png_ptr, info_ptr, &unknowns); DEBUG_PRINTF("num_unknowns %i\n", num_unknowns); if (num_unknowns) { - have_label_delta = have_label_data = have_background = have_foreground = - FALSE; + have_label_delta = have_label_data = have_background = have_foreground = FALSE; ldelta = ldata = fgnd = bgnd = FALSE; /* Need to get things in order, as we can't enforce any order in custom chunks, @@ -28765,7 +27406,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) blured when scaled one) */ for (u = 0; u < num_unknowns; u++) { - DEBUG_PRINTF("%s, %d\n", unknowns[u].name, (int) unknowns[u].size); + DEBUG_PRINTF("%s, %d\n", unknowns[u].name, (int)unknowns[u].size); if (chunk_is_valid("tpDT", unknowns[u])) { @@ -28777,9 +27418,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); - fprintf(stderr, - "\nError: Couldn't load the data embedded in %s\n\n", - fname); + fprintf(stderr, "\nError: Couldn't load the data embedded in %s\n\n", fname); draw_tux_text(TUX_OOPS, strerror(errno), 0); SDL_FreeSurface(org_surf); return; /* Refusing to go further with the other chunks */ @@ -28791,7 +27430,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) CHAR_PTR_TMP = fgets(control, 49, fi); CHAR_PTR_TMP = fgets(control, 49, fi); CHAR_PTR_TMP = fgets(control, 49, fi); - (void) CHAR_PTR_TMP; + (void)CHAR_PTR_TMP; free(control); /* fi will be closed in load_starter_id() */ @@ -28835,9 +27474,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) { DEBUG_PRINTF("Valid tpLD\n"); - unc_buff = - get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLD", - unknowns[u], &unc_size); + unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLD", unknowns[u], &unc_size); if (unc_buff == NULL) { if (are_labels()) @@ -28855,13 +27492,11 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) for (j = 0; j < hh; j++) for (i = 0; i < ww; i++) { - if ((Uint8) unc_buff[4 * j * ww + 4 * i + 3] == - SDL_ALPHA_OPAQUE) + if ((Uint8) unc_buff[4 * j * ww + 4 * i + 3] == SDL_ALPHA_OPAQUE) putpixels[org_surf->format->BytesPerPixel] (org_surf, i, j, SDL_MapRGB - (org_surf-> - format, + (org_surf->format, unc_buff[4 * (j * ww @@ -28870,17 +27505,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) unc_buff[4 * (j * ww - + - i) - + - 1], - unc_buff[4 * - (j * - ww - + - i) - + - 2])); + + i) + 1], unc_buff[4 * (j * ww + i) + 2])); } } @@ -28895,9 +27520,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) { DEBUG_PRINTF("Valid tpLL\n"); - unc_buff = - get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLL", - unknowns[u], &unc_size); + unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpLL", unknowns[u], &unc_size); if (unc_buff == NULL) { SDL_FreeSurface(org_surf); @@ -28908,12 +27531,9 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) fi = fmemopen(unc_buff, unc_size, "rb"); if (fi == NULL) { - fprintf(stderr, - "Can't recover the label data embedded in %s, error in create file stream\n\n", - fname); + fprintf(stderr, "Can't recover the label data embedded in %s, error in create file stream\n\n", fname); fclose(fp); - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp) NULL); + png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); free(unc_buff); SDL_FreeSurface(org_surf); @@ -28932,10 +27552,13 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) } /* Apply the original canvas */ - if (ldelta && ldata) { + if (ldelta && ldata) + { DEBUG_PRINTF("Smearing org_surf @ 9\n"); autoscale_copy_smear_free(org_surf, canvas, SDL_BlitSurface); - } else { + } + else + { SDL_FreeSurface(org_surf); } @@ -28944,25 +27567,18 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) { for (u = 0; u < num_unknowns; u++) { - if ((starter_modified || !img_starter_bkgd) - && chunk_is_valid("tpBG", unknowns[u])) + if ((starter_modified || !img_starter_bkgd) && chunk_is_valid("tpBG", unknowns[u])) { - unc_buff = - get_chunk_data(fp, fname, png_ptr, info_ptr, "tpBG", - unknowns[u], &unc_size); + unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpBG", unknowns[u], &unc_size); if (unc_buff == NULL) return; aux_surf = SDL_CreateRGBSurface(0, ww, hh, canvas->format->BitsPerPixel, - canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Gmask, 0); + canvas->format->Rmask, canvas->format->Gmask, canvas->format->Gmask, 0); if (aux_surf == NULL) { #ifdef DEBUG - fprintf(stderr, - "Can't recover the background data embedded in %s, error in create aux image\n\n", - fname); + fprintf(stderr, "Can't recover the background data embedded in %s, error in create aux image\n\n", fname); #endif fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); @@ -28986,12 +27602,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) 3 * i], unc_buff[3 * j * ww + - 3 * i + - 1], - unc_buff[3 * j * - ww + - 3 * i + - 2])); + 3 * i + 1], unc_buff[3 * j * ww + 3 * i + 2])); SDL_UnlockSurface(aux_surf); if (img_starter_bkgd) @@ -29002,45 +27613,34 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) img_starter_bkgd = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h, - canvas->format-> - BitsPerPixel, + canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, - 0); + canvas->format->Gmask, canvas->format->Bmask, 0); /* FIXME: How to handle starter/template scaling/smearing options!? -bjk 2023.02.10 */ DEBUG_PRINTF("Smearing embedded bkgd @ 10\n"); - autoscale_copy_smear_free(aux_surf, img_starter_bkgd, - SDL_BlitSurface); + autoscale_copy_smear_free(aux_surf, img_starter_bkgd, SDL_BlitSurface); } free(unc_buff); } - if ((starter_modified || !img_starter) - && chunk_is_valid("tpFG", unknowns[u])) + if ((starter_modified || !img_starter) && chunk_is_valid("tpFG", unknowns[u])) { DEBUG_PRINTF("Frgd!!!\n"); - unc_buff = - get_chunk_data(fp, fname, png_ptr, info_ptr, "tpFG", - unknowns[u], &unc_size); + unc_buff = get_chunk_data(fp, fname, png_ptr, info_ptr, "tpFG", unknowns[u], &unc_size); if (unc_buff == NULL) return; aux_surf = SDL_CreateRGBSurface(canvas->flags, ww, hh, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Gmask, - TPAINT_AMASK); + canvas->format->Gmask, canvas->format->Gmask, TPAINT_AMASK); if (aux_surf == NULL) { - fprintf(stderr, - "Can't recover the foreground data embedded in %s, error in create aux image\n\n", - fname); + fprintf(stderr, "Can't recover the foreground data embedded in %s, error in create aux image\n\n", fname); fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL); free(unc_buff); @@ -29067,12 +27667,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) 1], unc_buff[4 * j * ww + - 4 * i + - 2], - unc_buff[4 * j * - ww + - 4 * i + - 3])); + 4 * i + 2], unc_buff[4 * j * ww + 4 * i + 3])); } SDL_UnlockSurface(aux_surf); @@ -29085,9 +27680,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) canvas->w, canvas->h, canvas->format->BitsPerPixel, canvas->format->Rmask, - canvas->format->Gmask, - canvas->format->Bmask, - TPAINT_AMASK); + canvas->format->Gmask, canvas->format->Bmask, TPAINT_AMASK); /* 3rd arg ignored for RGBA surfaces */ // SDL_SetAlpha(aux_surf, SDL_RLEACCEL, SDL_ALPHA_OPAQUE); @@ -29096,8 +27689,7 @@ void load_embedded_data(char *fname, SDL_Surface * org_surf) /* FIXME: How to handle starter/template scaling/smearing options!? -bjk 2023.02.10 */ DEBUG_PRINTF("Smearing embedded foreground @ 11\n"); - autoscale_copy_smear_free(aux_surf, img_starter, - NondefectiveBlit); + autoscale_copy_smear_free(aux_surf, img_starter, NondefectiveBlit); // SDL_SetAlpha(img_starter, SDL_ALPHA_OPAQUE); SDL_SetSurfaceBlendMode(img_starter, SDL_BLENDMODE_NONE); @@ -29157,8 +27749,7 @@ static void show_available_papersizes(int exitcode) /** * FIXME */ -static void parse_file_options(struct cfginfo *restrict tmpcfg, - const char *filename) +static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *filename) { char str[256]; char *arg; @@ -29183,9 +27774,7 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, /* Expecting alphanumeric at the beginning of a line; ignore (and complain about) the rest */ if (!isalnum(*str)) { - fprintf(stderr, - "Warning: do not understand '%s' on line %d of '%s'\n", str, - line, filename); + fprintf(stderr, "Warning: do not understand '%s' on line %d of '%s'\n", str, line, filename); continue; } @@ -29197,9 +27786,7 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, } else { - fprintf(stderr, - "Warning: do not understand '%s' on line %d of '%s'\n", str, - line, filename); + fprintf(stderr, "Warning: do not understand '%s' on line %d of '%s'\n", str, line, filename); continue; } @@ -29328,12 +27915,10 @@ static void tmpcfg_merge(struct cfginfo *loser, const struct cfginfo *winner) { const char *cfgitem; - memcpy(&cfgitem, i * sizeof(const char *) + (const char *) winner, - sizeof cfgitem); + memcpy(&cfgitem, i * sizeof(const char *) + (const char *)winner, sizeof cfgitem); if (!cfgitem) continue; - memcpy(i * sizeof(const char *) + (char *) loser, &cfgitem, - sizeof cfgitem); + memcpy(i * sizeof(const char *) + (char *)loser, &cfgitem, sizeof cfgitem); } } @@ -29396,10 +27981,8 @@ static void setup_config(char *argv[]) char buffer[B_PATH_NAME_LENGTH + B_FILE_NAME_LENGTH]; status_t result; - result = - find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, - sizeof(buffer)); - asprintf((char **) &savedir, "%s/%s", buffer, "TuxPaint"); + result = find_directory(B_USER_SETTINGS_DIRECTORY, volume, false, buffer, sizeof(buffer)); + asprintf((char **)&savedir, "%s/%s", buffer, "TuxPaint"); #elif __APPLE__ savedir = strdup(apple_preferencesPath()); #elif __ANDROID__ @@ -29407,7 +27990,7 @@ static void setup_config(char *argv[]) #else int tmp; - tmp = asprintf((char **) &savedir, "%s/%s", home, ".tuxpaint"); + tmp = asprintf((char **)&savedir, "%s/%s", home, ".tuxpaint"); if (tmp < 0) { fprintf(stderr, "Can't set savedir\n"); @@ -29432,6 +28015,7 @@ static void setup_config(char *argv[]) #elif __ANDROID__ picturesdir = strdup(SDL_AndroidGetExternalStoragePath()); char *substring = strstr(picturesdir, "/Android"); + if (substring != NULL) { strcpy(substring, "/Pictures"); @@ -29458,8 +28042,7 @@ static void setup_config(char *argv[]) #elif defined(__ANDROID__) /* Try to find the user's config file */ /* This file is writed by the tuxpaint config activity when the user runs it */ - safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", - SDL_AndroidGetExternalStoragePath()); + safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", SDL_AndroidGetExternalStoragePath()); #else @@ -29491,8 +28074,7 @@ static void setup_config(char *argv[]) folder & extension inconsistency with Tux Paint Config application) */ /* macOS, iOS: Use a "tuxpaint.cfg" file in the *global* Tux Paint application support folder */ - safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", - apple_globalPreferencesPath()); + safe_snprintf(str, sizeof(str), "%s/tuxpaint.cfg", apple_globalPreferencesPath()); parse_file_options(&tmpcfg_sys, str); #elif defined(__ANDROID__) /* Load the config file we provide in assets/etc/tuxpaint.cfg */ @@ -29509,7 +28091,7 @@ static void setup_config(char *argv[]) if (tmpcfg.savedir) { - free((char *) savedir); + free((char *)savedir); savedir = tmpcfg.savedir; } @@ -29521,9 +28103,7 @@ static void setup_config(char *argv[]) tmpcfg.parsertmp_lang = NULL; if (tmpcfg.parsertmp_locale == PARSE_CLOBBER) tmpcfg.parsertmp_locale = NULL; - button_label_y_nudge = - setup_i18n(tmpcfg.parsertmp_lang, tmpcfg.parsertmp_locale, - &num_wished_langs); + button_label_y_nudge = setup_i18n(tmpcfg.parsertmp_lang, tmpcfg.parsertmp_locale, &num_wished_langs); /* FIXME: most of this is not required before starting the font scanner */ @@ -29586,18 +28166,14 @@ static void setup_config(char *argv[]) int w = strtoul(tmpcfg.parsertmp_windowsize, &endp1, 10); int h = strtoul(endp1 + 1, &endp2, 10); - if (tmpcfg.parsertmp_windowsize == endp1 || endp1 + 1 == endp2 - || *endp1 != 'x' || *endp2) + if (tmpcfg.parsertmp_windowsize == endp1 || endp1 + 1 == endp2 || *endp1 != 'x' || *endp2) { - fprintf(stderr, "Window size '%s' is not understood.\n", - tmpcfg.parsertmp_windowsize); + fprintf(stderr, "Window size '%s' is not understood.\n", tmpcfg.parsertmp_windowsize); exit(97); } - if (w < 500 || w > 32000 || h < 480 || h > 32000 || h > w * 3 - || w > h * 4) + if (w < 500 || w > 32000 || h < 480 || h > 32000 || h > w * 3 || w > h * 4) { - fprintf(stderr, "Window size '%s' is not reasonable.\n", - tmpcfg.parsertmp_windowsize); + fprintf(stderr, "Window size '%s' is not reasonable.\n", tmpcfg.parsertmp_windowsize); exit(93); } WINDOW_WIDTH = w; @@ -29616,11 +28192,9 @@ static void setup_config(char *argv[]) button_size_auto = 1; else { - if (strtof(tmpcfg.button_size, NULL) < 24 - || strtof(tmpcfg.button_size, NULL) > 192) + if (strtof(tmpcfg.button_size, NULL) < 24 || strtof(tmpcfg.button_size, NULL) > 192) { - fprintf(stderr, "Button size (now %s) must be between 24 and 192.\n", - tmpcfg.button_size); + fprintf(stderr, "Button size (now %s) must be between 24 and 192.\n", tmpcfg.button_size); exit(1); } button_scale = strtof(tmpcfg.button_size, NULL) / ORIGINAL_BUTTON_SIZE; @@ -29632,8 +28206,7 @@ static void setup_config(char *argv[]) { if (strtof(tmpcfg.colors_rows, NULL) > 3) { - fprintf(stderr, "Color rows (now %s) must be between 1 and 3.\n", - tmpcfg.colors_rows); + fprintf(stderr, "Color rows (now %s) must be between 1 and 3.\n", tmpcfg.colors_rows); exit(1); } colors_rows = strtof(tmpcfg.colors_rows, NULL); @@ -29690,11 +28263,9 @@ static void setup_config(char *argv[]) } else { - if (strtof(tmpcfg.joystick_dev, NULL) < 0 - || strtof(tmpcfg.joystick_dev, NULL) > 100) + if (strtof(tmpcfg.joystick_dev, NULL) < 0 || strtof(tmpcfg.joystick_dev, NULL) > 100) { - fprintf(stderr, "Joystick dev (now %s) must be between 0 and 100.\n", - tmpcfg.joystick_dev); + fprintf(stderr, "Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev); exit(1); } joystick_dev = strtof(tmpcfg.joystick_dev, NULL); @@ -29702,75 +28273,59 @@ static void setup_config(char *argv[]) } if (tmpcfg.joystick_slowness) { - if (strtof(tmpcfg.joystick_slowness, NULL) < 0 - || strtof(tmpcfg.joystick_slowness, NULL) > 500) + if (strtof(tmpcfg.joystick_slowness, NULL) < 0 || strtof(tmpcfg.joystick_slowness, NULL) > 500) { - fprintf(stderr, - "Joystick slowness (now %s) must be between 0 and 500.\n", - tmpcfg.joystick_slowness); + fprintf(stderr, "Joystick slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_slowness); exit(1); } joystick_slowness = strtof(tmpcfg.joystick_slowness, NULL); } if (tmpcfg.joystick_lowthreshold) { - if (strtof(tmpcfg.joystick_lowthreshold, NULL) < 0 - || strtof(tmpcfg.joystick_lowthreshold, NULL) > 32766) + if (strtof(tmpcfg.joystick_lowthreshold, NULL) < 0 || strtof(tmpcfg.joystick_lowthreshold, NULL) > 32766) { /* FIXME: Find better exit code */ - fprintf(stderr, - "Joystick lower threshold (now %s) must be between 0 and 32766", - tmpcfg.joystick_lowthreshold); + fprintf(stderr, "Joystick lower threshold (now %s) must be between 0 and 32766", tmpcfg.joystick_lowthreshold); exit(1); } joystick_low_threshold = strtof(tmpcfg.joystick_lowthreshold, NULL); } if (tmpcfg.joystick_maxsteps) { - if (strtof(tmpcfg.joystick_maxsteps, NULL) < 1 - || strtof(tmpcfg.joystick_maxsteps, NULL) > 7) + if (strtof(tmpcfg.joystick_maxsteps, NULL) < 1 || strtof(tmpcfg.joystick_maxsteps, NULL) > 7) { /* FIXME: Find better exit code */ - fprintf(stderr, "Joystick max steps (now %s) must be between 1 and 7", - tmpcfg.joystick_maxsteps); + fprintf(stderr, "Joystick max steps (now %s) must be between 1 and 7", tmpcfg.joystick_maxsteps); exit(1); } joystick_maxsteps = strtof(tmpcfg.joystick_maxsteps, NULL); } if (tmpcfg.joystick_hat_slowness) { - if (strtof(tmpcfg.joystick_hat_slowness, NULL) < 0 - || strtof(tmpcfg.joystick_hat_slowness, NULL) > 500) + if (strtof(tmpcfg.joystick_hat_slowness, NULL) < 0 || strtof(tmpcfg.joystick_hat_slowness, NULL) > 500) { - fprintf(stderr, - "Joystick hat slowness (now %s) must be between 0 and 500.\n", - tmpcfg.joystick_hat_slowness); + fprintf(stderr, "Joystick hat slowness (now %s) must be between 0 and 500.\n", tmpcfg.joystick_hat_slowness); exit(1); } joystick_hat_slowness = strtof(tmpcfg.joystick_hat_slowness, NULL); } if (tmpcfg.joystick_hat_timeout) { - if (strtof(tmpcfg.joystick_hat_timeout, NULL) < 0 - || strtof(tmpcfg.joystick_hat_timeout, NULL) > 3000) + if (strtof(tmpcfg.joystick_hat_timeout, NULL) < 0 || strtof(tmpcfg.joystick_hat_timeout, NULL) > 3000) { /* FIXME: Find better exit code */ - fprintf(stderr, - "Joystick hat timeout (now %s) must be between 0 and 3000", - tmpcfg.joystick_hat_timeout); + fprintf(stderr, "Joystick hat timeout (now %s) must be between 0 and 3000", tmpcfg.joystick_hat_timeout); exit(1); } joystick_hat_timeout = strtof(tmpcfg.joystick_hat_timeout, NULL); } if (tmpcfg.joystick_button_escape) { - if (strtof(tmpcfg.joystick_button_escape, NULL) < 0 - || strtof(tmpcfg.joystick_button_escape, NULL) > 254) + if (strtof(tmpcfg.joystick_button_escape, NULL) < 0 || strtof(tmpcfg.joystick_button_escape, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button escape shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_escape); + "Joystick button escape shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_escape); exit(1); } joystick_button_escape = strtof(tmpcfg.joystick_button_escape, NULL); @@ -29786,8 +28341,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectbrushtool); exit(1); } - joystick_button_selectbrushtool = - strtof(tmpcfg.joystick_button_selectbrushtool, NULL); + joystick_button_selectbrushtool = strtof(tmpcfg.joystick_button_selectbrushtool, NULL); } if (tmpcfg.joystick_button_selectstamptool) { @@ -29800,8 +28354,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectstamptool); exit(1); } - joystick_button_selectstamptool = - strtof(tmpcfg.joystick_button_selectstamptool, NULL); + joystick_button_selectstamptool = strtof(tmpcfg.joystick_button_selectstamptool, NULL); } if (tmpcfg.joystick_button_selectlinestool) { @@ -29814,8 +28367,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectlinestool); exit(1); } - joystick_button_selectlinestool = - strtof(tmpcfg.joystick_button_selectlinestool, NULL); + joystick_button_selectlinestool = strtof(tmpcfg.joystick_button_selectlinestool, NULL); } if (tmpcfg.joystick_button_selectshapestool) { @@ -29828,8 +28380,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectshapestool); exit(1); } - joystick_button_selectshapestool = - strtof(tmpcfg.joystick_button_selectshapestool, NULL); + joystick_button_selectshapestool = strtof(tmpcfg.joystick_button_selectshapestool, NULL); } if (tmpcfg.joystick_button_selecttexttool) { @@ -29842,8 +28393,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selecttexttool); exit(1); } - joystick_button_selecttexttool = - strtof(tmpcfg.joystick_button_selecttexttool, NULL); + joystick_button_selecttexttool = strtof(tmpcfg.joystick_button_selecttexttool, NULL); } if (tmpcfg.joystick_button_selectlabeltool) { @@ -29856,8 +28406,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectlabeltool); exit(1); } - joystick_button_selectlabeltool = - strtof(tmpcfg.joystick_button_selectlabeltool, NULL); + joystick_button_selectlabeltool = strtof(tmpcfg.joystick_button_selectlabeltool, NULL); } if (tmpcfg.joystick_button_selectfilltool) { @@ -29870,8 +28419,7 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectfilltool); exit(1); } - joystick_button_selectfilltool = - strtof(tmpcfg.joystick_button_selectfilltool, NULL); + joystick_button_selectfilltool = strtof(tmpcfg.joystick_button_selectfilltool, NULL); } if (tmpcfg.joystick_button_selectmagictool) { @@ -29884,31 +28432,26 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selectmagictool); exit(1); } - joystick_button_selectmagictool = - strtof(tmpcfg.joystick_button_selectmagictool, NULL); + joystick_button_selectmagictool = strtof(tmpcfg.joystick_button_selectmagictool, NULL); } if (tmpcfg.joystick_button_undo) { - if (strtof(tmpcfg.joystick_button_undo, NULL) < 0 - || strtof(tmpcfg.joystick_button_undo, NULL) > 254) + if (strtof(tmpcfg.joystick_button_undo, NULL) < 0 || strtof(tmpcfg.joystick_button_undo, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button undo shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_undo); + "Joystick button undo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_undo); exit(1); } joystick_button_undo = strtof(tmpcfg.joystick_button_undo, NULL); } if (tmpcfg.joystick_button_redo) { - if (strtof(tmpcfg.joystick_button_redo, NULL) < 0 - || strtof(tmpcfg.joystick_button_redo, NULL) > 254) + if (strtof(tmpcfg.joystick_button_redo, NULL) < 0 || strtof(tmpcfg.joystick_button_redo, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button redo shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_redo); + "Joystick button redo shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_redo); exit(1); } joystick_button_redo = strtof(tmpcfg.joystick_button_redo, NULL); @@ -29924,52 +28467,43 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_selecterasertool); exit(1); } - joystick_button_selecterasertool = - strtof(tmpcfg.joystick_button_selecterasertool, NULL); + joystick_button_selecterasertool = strtof(tmpcfg.joystick_button_selecterasertool, NULL); } if (tmpcfg.joystick_button_new) { - if (strtof(tmpcfg.joystick_button_new, NULL) < 0 - || strtof(tmpcfg.joystick_button_new, NULL) > 254) + if (strtof(tmpcfg.joystick_button_new, NULL) < 0 || strtof(tmpcfg.joystick_button_new, NULL) > 254) { /* FIXME: Find better exit code */ - fprintf(stderr, - "Joystick button new shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_new); + fprintf(stderr, "Joystick button new shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_new); exit(1); } joystick_button_new = strtof(tmpcfg.joystick_button_new, NULL); } if (tmpcfg.joystick_button_open) { - if (strtof(tmpcfg.joystick_button_open, NULL) < 0 - || strtof(tmpcfg.joystick_button_open, NULL) > 254) + if (strtof(tmpcfg.joystick_button_open, NULL) < 0 || strtof(tmpcfg.joystick_button_open, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button open shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_open); + "Joystick button open shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_open); exit(1); } joystick_button_open = strtof(tmpcfg.joystick_button_open, NULL); } if (tmpcfg.joystick_button_save) { - if (strtof(tmpcfg.joystick_button_save, NULL) < 0 - || strtof(tmpcfg.joystick_button_save, NULL) > 254) + if (strtof(tmpcfg.joystick_button_save, NULL) < 0 || strtof(tmpcfg.joystick_button_save, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button save shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_save); + "Joystick button save shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_save); exit(1); } joystick_button_save = strtof(tmpcfg.joystick_button_save, NULL); } if (tmpcfg.joystick_button_pagesetup) { - if (strtof(tmpcfg.joystick_button_pagesetup, NULL) < 0 - || strtof(tmpcfg.joystick_button_pagesetup, NULL) > 254) + if (strtof(tmpcfg.joystick_button_pagesetup, NULL) < 0 || strtof(tmpcfg.joystick_button_pagesetup, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, @@ -29977,18 +28511,15 @@ static void setup_config(char *argv[]) tmpcfg.joystick_button_pagesetup); exit(1); } - joystick_button_pagesetup = - strtof(tmpcfg.joystick_button_pagesetup, NULL); + joystick_button_pagesetup = strtof(tmpcfg.joystick_button_pagesetup, NULL); } if (tmpcfg.joystick_button_print) { - if (strtof(tmpcfg.joystick_button_print, NULL) < 0 - || strtof(tmpcfg.joystick_button_print, NULL) > 254) + if (strtof(tmpcfg.joystick_button_print, NULL) < 0 || strtof(tmpcfg.joystick_button_print, NULL) > 254) { /* FIXME: Find better exit code */ fprintf(stderr, - "Joystick button print shortcurt (now %s) must be between 0 and 254", - tmpcfg.joystick_button_print); + "Joystick button print shortcurt (now %s) must be between 0 and 254", tmpcfg.joystick_button_print); exit(1); } joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL); @@ -29997,19 +28528,16 @@ static void setup_config(char *argv[]) { char *token; - token = strtok((char *) tmpcfg.joystick_buttons_ignore, ","); + token = strtok((char *)tmpcfg.joystick_buttons_ignore, ","); while (token != NULL) { if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254) { /* FIXME: Find better exit code */ - fprintf(stderr, - "Joystick buttons must be between 0 and 254 (don't like %s)", - tmpcfg.joystick_buttons_ignore); + fprintf(stderr, "Joystick buttons must be between 0 and 254 (don't like %s)", tmpcfg.joystick_buttons_ignore); exit(1); } - joystick_buttons_ignore[joystick_buttons_ignore_len++] = - strtof(token, NULL); + joystick_buttons_ignore[joystick_buttons_ignore_len++] = strtof(token, NULL); token = strtok(NULL, ","); } } @@ -30028,8 +28556,7 @@ static void setup_config(char *argv[]) } DEBUG_PRINTF("\n\nPromptless save:\nask: %d\nnew: %d\nover: %d\n\n", - _promptless_save_over_ask, _promptless_save_over_new, - _promptless_save_over); + _promptless_save_over_ask, _promptless_save_over_new, _promptless_save_over); if (_promptless_save_over_ask) { @@ -30108,7 +28635,7 @@ static void chdir_to_binary(char *argv0) */ } #else - (void) argv0; + (void)argv0; #endif } @@ -30129,8 +28656,7 @@ static void setup_colors(void) fi = fopen(colorfile, "r"); if (fi == NULL) { - fprintf(stderr, - "\nWarning, could not open color file. Using defaults.\n"); + fprintf(stderr, "\nWarning, could not open color file. Using defaults.\n"); perror(colorfile); colorfile[0] = '\0'; } @@ -30150,10 +28676,8 @@ static void setup_colors(void) { if (NUM_COLORS + 1 > max) { - color_hexes = - realloc(color_hexes, sizeof(Uint8 *) * (max + per)); - color_names = - realloc(color_names, sizeof(char *) * (max + per)); + color_hexes = realloc(color_hexes, sizeof(Uint8 *) * (max + per)); + color_names = realloc(color_names, sizeof(char *) * (max + per)); for (i = max; i < max + per; i++) color_hexes[i] = malloc(sizeof(Uint8) * 3); @@ -30163,8 +28687,7 @@ static void setup_colors(void) /* FIXME: This and get_starter_template_options() needs to be modularized -bjk 2023.02.10 */ - while (str[strlen(str) - 1] == '\n' - || str[strlen(str) - 1] == '\r') + while (str[strlen(str) - 1] == '\n' || str[strlen(str) - 1] == '\r') str[strlen(str) - 1] = '\0'; if (str[0] == '#') @@ -30177,12 +28700,9 @@ static void setup_colors(void) { /* Byte (#rrggbb) form */ - color_hexes[NUM_COLORS][0] = - (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[1]); - color_hexes[NUM_COLORS][1] = - (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[3]); - color_hexes[NUM_COLORS][2] = - (hex2dec(tmp_str[4]) << 4) + hex2dec(tmp_str[5]); + color_hexes[NUM_COLORS][0] = (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[1]); + color_hexes[NUM_COLORS][1] = (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[3]); + color_hexes[NUM_COLORS][2] = (hex2dec(tmp_str[4]) << 4) + hex2dec(tmp_str[5]); color_names[NUM_COLORS] = strdup(str + count); NUM_COLORS++; @@ -30191,12 +28711,9 @@ static void setup_colors(void) { /* Nybble (#rgb) form */ - color_hexes[NUM_COLORS][0] = - (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[0]); - color_hexes[NUM_COLORS][1] = - (hex2dec(tmp_str[1]) << 4) + hex2dec(tmp_str[1]); - color_hexes[NUM_COLORS][2] = - (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[2]); + color_hexes[NUM_COLORS][0] = (hex2dec(tmp_str[0]) << 4) + hex2dec(tmp_str[0]); + color_hexes[NUM_COLORS][1] = (hex2dec(tmp_str[1]) << 4) + hex2dec(tmp_str[1]); + color_hexes[NUM_COLORS][2] = (hex2dec(tmp_str[2]) << 4) + hex2dec(tmp_str[2]); color_names[NUM_COLORS] = strdup(str + count); NUM_COLORS++; @@ -30207,10 +28724,9 @@ static void setup_colors(void) /* Assume int form */ if (sscanf(str, "%hu %hu %hu %n", - (short unsigned int *) &(color_hexes[NUM_COLORS][0]), - (short unsigned int *) &(color_hexes[NUM_COLORS][1]), - (short unsigned int *) &(color_hexes[NUM_COLORS][2]), - &count) >= 3) + (short unsigned int *)&(color_hexes[NUM_COLORS][0]), + (short unsigned int *)&(color_hexes[NUM_COLORS][1]), + (short unsigned int *)&(color_hexes[NUM_COLORS][2]), &count) >= 3) { color_names[NUM_COLORS] = strdup(str + count); NUM_COLORS++; @@ -30223,8 +28739,7 @@ static void setup_colors(void) if (NUM_COLORS < 2) { - fprintf(stderr, - "\nWarning, not enough colors in color file. Using defaults.\n"); + fprintf(stderr, "\nWarning, not enough colors in color file. Using defaults.\n"); fprintf(stderr, "%s\n", colorfile); colorfile[0] = '\0'; @@ -30263,15 +28778,12 @@ static void setup_colors(void) /* Add room for dynamic color options at the end of the list: */ - color_hexes = - (Uint8 **) realloc(color_hexes, sizeof(Uint8 *) * (NUM_COLORS + 3)); - color_names = - (char **) realloc(color_names, sizeof(char *) * (NUM_COLORS + 3)); + color_hexes = (Uint8 **) realloc(color_hexes, sizeof(Uint8 *) * (NUM_COLORS + 3)); + color_names = (char **)realloc(color_names, sizeof(char *) * (NUM_COLORS + 3)); /* Add "Color Select" color: */ - color_names[NUM_COLORS] = - strdup(gettext("Select a color from your drawing.")); + color_names[NUM_COLORS] = strdup(gettext("Select a color from your drawing.")); color_hexes[NUM_COLORS] = (Uint8 *) malloc(sizeof(Uint8) * 3); color_hexes[NUM_COLORS][0] = 0; color_hexes[NUM_COLORS][1] = 0; @@ -30350,8 +28862,7 @@ static void do_lock_file(void) ("You have already started tuxpaint less than 30 seconds ago.\n" "To prevent multiple executions by mistake, TuxPaint will not run\n" "before 30 seconds have elapsed since it was last started.\n" - "\n" - "You can also use the --nolockfile argument, see tuxpaint(1).\n\n"); + "\n" "You can also use the --nolockfile argument, see tuxpaint(1).\n\n"); free(lock_fname); @@ -30384,8 +28895,7 @@ static void do_lock_file(void) { fprintf(stderr, "\nWarning: I couldn't create the lockfile (%s)\n" - "The error that occurred was:\n" "%s\n\n", lock_fname, - strerror(errno)); + "The error that occurred was:\n" "%s\n\n", lock_fname, strerror(errno)); } free(lock_fname); @@ -30415,8 +28925,7 @@ int TP_EventFilter( __attribute__((unused)) event->type == SDL_TEXTINPUT || event->type == SDL_APP_WILLENTERBACKGROUND || event->type == SDL_APP_WILLENTERFOREGROUND || - event->type == SDL_APP_DIDENTERBACKGROUND - || event->type == SDL_APP_DIDENTERFOREGROUND) + event->type == SDL_APP_DIDENTERBACKGROUND || event->type == SDL_APP_DIDENTERFOREGROUND) return 1; return 0; @@ -30477,18 +28986,15 @@ static void setup(void) #endif #ifndef WIN32 - putenv((char *) "SDL_VIDEO_X11_WMCLASS=TuxPaint.TuxPaint"); + putenv((char *)"SDL_VIDEO_X11_WMCLASS=TuxPaint.TuxPaint"); #endif if (disable_screensaver == 0) { - putenv((char *) "SDL_VIDEO_ALLOW_SCREENSAVER=1"); - if (SDL_MAJOR_VERSION < 2 - || (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 - && SDL_PATCHLEVEL < 2)) + putenv((char *)"SDL_VIDEO_ALLOW_SCREENSAVER=1"); + if (SDL_MAJOR_VERSION < 2 || (SDL_MAJOR_VERSION == 2 && SDL_MINOR_VERSION == 0 && SDL_PATCHLEVEL < 2)) { - fprintf(stderr, - "Note: 'allowscreensaver' requires SDL 1.2.12 or higher\n"); + fprintf(stderr, "Note: 'allowscreensaver' requires SDL 1.2.12 or higher\n"); } } @@ -30514,8 +29020,7 @@ static void setup(void) /* worked, w/o sound */ fprintf(stderr, "\nWarning: I could not initialize audio!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", olderr); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", olderr); free(olderr); } else @@ -30523,8 +29028,7 @@ static void setup(void) { fprintf(stderr, "\nError: I could not initialize video and/or the timer!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); exit(1); } } @@ -30559,8 +29063,7 @@ static void setup(void) joystick = SDL_JoystickOpen(joystick_dev); if (joystick == NULL) { - fprintf(stderr, "Could not open joystick device %d: %s\n", joystick_dev, - SDL_GetError()); + fprintf(stderr, "Could not open joystick device %d: %s\n", joystick_dev, SDL_GetError()); } else { @@ -30582,9 +29085,7 @@ static void setup(void) { fprintf(stderr, "\nWarning: I could not set up audio for 44100 Hz " - "16-bit stereo.\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "16-bit stereo.\n" "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); use_sound = 0; } @@ -30597,8 +29098,7 @@ static void setup(void) { fprintf(stderr, "\nWarning: I couldn't open a sound file:\n%s\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", sound_fnames[i], SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", sound_fnames[i], SDL_GetError()); use_sound = 0; } } @@ -30617,8 +29117,7 @@ static void setup(void) { fprintf(stderr, "\nError: I could not initialize the font (TTF) library!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); SDL_Quit(); exit(1); @@ -30641,8 +29140,7 @@ static void setup(void) #if defined __ANDROID__ SDL_SetHint(SDL_HINT_ORIENTATIONS, "Portrait"); #else - fprintf(stderr, - "Warning: Asking for native screen size overrides request to rotate orientation.\n"); + fprintf(stderr, "Warning: Asking for native screen size overrides request to rotate orientation.\n"); #endif } else @@ -30661,8 +29159,7 @@ static void setup(void) { if (!fullscreen) { - fprintf(stderr, - "Warning: Asking for native screensize in a window. Ignoring.\n"); + fprintf(stderr, "Warning: Asking for native screensize in a window. Ignoring.\n"); } else { @@ -30680,8 +29177,7 @@ static void setup(void) window_screen = SDL_CreateWindow("Tux Paint", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - WINDOW_WIDTH, WINDOW_HEIGHT, - SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE); + WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_HWSURFACE); if (window_screen == NULL) printf("window_screen = NULL 1\n"); @@ -30689,8 +29185,7 @@ static void setup(void) window_screen = SDL_CreateWindow(NULL, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - WINDOW_WIDTH, WINDOW_HEIGHT, - SDL_WINDOW_FULLSCREEN_DESKTOP); + WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_FULLSCREEN_DESKTOP); if (window_screen == NULL) printf("window_screen = NULL 2\n"); #endif @@ -30737,6 +29232,7 @@ static void setup(void) if (ww > hh) { int tmp; + tmp = ww; ww = hh; hh = tmp; @@ -30747,6 +29243,7 @@ static void setup(void) if (hh > ww) { int tmp; + tmp = ww; ww = hh; hh = tmp; @@ -30760,20 +29257,15 @@ static void setup(void) hh = WINDOW_HEIGHT; } - texture = - SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, - SDL_TEXTUREACCESS_STATIC, ww, hh); + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, ww, hh); - screen = - SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); + screen = SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); if (screen == NULL) { fprintf(stderr, "\nWarning: I could not open the display in fullscreen mode.\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); fullscreen = 0; } @@ -30803,19 +29295,31 @@ static void setup(void) max_scrn_h = -1; num_displays = SDL_GetNumVideoDisplays(); - if (num_displays == 0) { + if (num_displays == 0) + { fprintf(stderr, "Warning: SDL_GetNumVideoDisplays() returned zero!"); - } else if (num_displays < 0) { + } + else if (num_displays < 0) + { fprintf(stderr, "Warning: SDL_GetNumVideoDisplays() failed: %s\n", SDL_GetError()); - } else { - for (i = 0; i < num_displays; i++) { + } + else + { + for (i = 0; i < num_displays; i++) + { res = SDL_GetCurrentDisplayMode(i, &mode); - if (res != 0) { + if (res != 0) + { fprintf(stderr, "Warning: SDL_GetCurrentDisplayMode() on display %d failed: %s\n", i, SDL_GetError()); - } else { - if (mode.w >= WINDOW_WIDTH && mode.h >= WINDOW_HEIGHT) { + } + else + { + if (mode.w >= WINDOW_WIDTH && mode.h >= WINDOW_HEIGHT) + { /* Found a display capable of the chosen window size */ - } else { + } + else + { if (mode.w >= max_scrn_w) max_scrn_w = mode.w; if (mode.h >= max_scrn_h) @@ -30825,16 +29329,21 @@ static void setup(void) } } - if (max_scrn_w == -1) { + if (max_scrn_w == -1) + { fprintf(stderr, "Warning: Could not query any display modes!?\n"); - } else if (num_displays == 1) { + } + else if (num_displays == 1) + { /* Only found one display, and window size is larger? Use that window size */ - if (WINDOW_WIDTH > max_scrn_w) { + if (WINDOW_WIDTH > max_scrn_w) + { fprintf(stderr, "Asked for window width (%d) larger than max screen width (%d)\n", WINDOW_WIDTH, max_scrn_w); WINDOW_WIDTH = max_scrn_w; } - if (WINDOW_HEIGHT > max_scrn_h) { + if (WINDOW_HEIGHT > max_scrn_h) + { fprintf(stderr, "Asked for window height (%d) larger than max screen height (%d)\n", WINDOW_HEIGHT, max_scrn_h); WINDOW_HEIGHT = max_scrn_h; } @@ -30843,39 +29352,41 @@ static void setup(void) /* SDL1.2 supported "SDL_VIDEO_WINDOW_POS", but SDL2 does not, so we implement it ourselves */ - if (getenv((char *) "SDL_VIDEO_WINDOW_POS") != NULL) + if (getenv((char *)"SDL_VIDEO_WINDOW_POS") != NULL) + { + char *winpos; + + winpos = getenv((char *)"SDL_VIDEO_WINDOW_POS"); + if (strcmp(winpos, "nopref") != 0) { - char * winpos; + if (strcmp(winpos, "center") == 0) + { + win_x = SDL_WINDOWPOS_CENTERED; + win_y = SDL_WINDOWPOS_CENTERED; + } + else + { + int success; - winpos = getenv((char *) "SDL_VIDEO_WINDOW_POS"); - if (strcmp(winpos, "nopref") != 0) { - if (strcmp(winpos, "center") == 0) { - win_x = SDL_WINDOWPOS_CENTERED; - win_y = SDL_WINDOWPOS_CENTERED; - } else { - int success; - - success = sscanf(winpos, "%d,%d", &win_x, &win_y); - if (success != 2) { - fprintf(stderr, "Warning: Cannot parse SDL_VIDEO_WINDOW_POS value of \"%s\"; ignoring\n", winpos); - win_x = SDL_WINDOWPOS_UNDEFINED; - win_y = SDL_WINDOWPOS_UNDEFINED; - } + success = sscanf(winpos, "%d,%d", &win_x, &win_y); + if (success != 2) + { + fprintf(stderr, "Warning: Cannot parse SDL_VIDEO_WINDOW_POS value of \"%s\"; ignoring\n", winpos); + win_x = SDL_WINDOWPOS_UNDEFINED; + win_y = SDL_WINDOWPOS_UNDEFINED; } } } + } /* Finally, ready to create a window! */ #ifdef USE_HWSURFACE - window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y, - WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_HWSURFACE); + window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_HWSURFACE); if (window_screen == NULL) printf("window_screen = NULL 3\n"); #else - window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y, - WINDOW_WIDTH, - WINDOW_HEIGHT, 0 /* no flags */ ); + window_screen = SDL_CreateWindow("Tux Paint", win_x, win_y, WINDOW_WIDTH, WINDOW_HEIGHT, 0 /* no flags */ ); if (window_screen == NULL) printf("window_screen = NULL 4\n"); #endif @@ -30889,20 +29400,15 @@ static void setup(void) renderer = SDL_CreateRenderer(window_screen, -1, 0); SDL_GL_GetDrawableSize(window_screen, &ww, &hh); - texture = - SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, - SDL_TEXTUREACCESS_STATIC, ww, hh); + texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, ww, hh); - screen = - SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); + screen = SDL_CreateRGBSurface(0, ww, hh, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); if (screen == NULL) { fprintf(stderr, "\nError: 1 I could not open the display.\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -30916,9 +29422,7 @@ static void setup(void) /* (Need to do this after native screen resolution is handled) */ if (button_size_auto) /* Automatic size of buttons, see https://sourceforge.net/p/tuxpaint/feature-requests/218/ */ - button_scale = - (float) min((48 * screen->w) / 800, - (48 * screen->h) / 600) / ORIGINAL_BUTTON_SIZE; + button_scale = (float)min((48 * screen->w) / 800, (48 * screen->h) / 600) / ORIGINAL_BUTTON_SIZE; setup_screen_layout(); set_color_picker_crosshair_size(); @@ -30945,16 +29449,13 @@ static void setup(void) if (big_title) - img_title_tuxpaint = - loadimage(DATA_PREFIX "images/title-tuxpaint-2x.png"); + img_title_tuxpaint = loadimage(DATA_PREFIX "images/title-tuxpaint-2x.png"); else img_title_tuxpaint = loadimage(DATA_PREFIX "images/title-tuxpaint.png"); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255)); - dest.x = - ((WINDOW_WIDTH - img_title->w - (img_title_tuxpaint->w / 2)) / 2) + - (img_title_tuxpaint->w / 2) + 20; + dest.x = ((WINDOW_WIDTH - img_title->w - (img_title_tuxpaint->w / 2)) / 2) + (img_title_tuxpaint->w / 2) + 20; dest.y = (WINDOW_HEIGHT - img_title->h); SDL_BlitSurface(img_title, NULL, screen, &dest); @@ -30983,8 +29484,7 @@ static void setup(void) { fprintf(stderr, "Warning: An SDL bug causes the fancy cursors to leave\n" "trails in fullscreen mode. Disabling fancy cursors.\n" - "(You can do this yourself with 'nofancycursors' option,\n" - "to avoid this warning in the future.)\n"); + "(You can do this yourself with 'nofancycursors' option,\n" "to avoid this warning in the future.)\n"); no_fancy_cursors = 1; } #endif @@ -31003,9 +29503,7 @@ static void setup(void) #endif /* this one first, because we need it yesterday */ - cursor_watch = - get_cursor(watch_bits, watch_mask_bits, watch_width, watch_height, - 14 / scale, 14 / scale); + cursor_watch = get_cursor(watch_bits, watch_mask_bits, watch_width, watch_height, 14 / scale, 14 / scale); do_setcursor(cursor_watch); show_progress_bar(screen); @@ -31020,12 +29518,10 @@ static void setup(void) DEBUG_PRINTF("Spawning Pango thread\n"); - fontconfig_thread = - SDL_CreateThread(generate_fontconfig_cache, "fontconfig_thread", NULL); + fontconfig_thread = SDL_CreateThread(generate_fontconfig_cache, "fontconfig_thread", NULL); if (fontconfig_thread == NULL) { - fprintf(stderr, "Failed to create Pango setup thread: %s\n", - SDL_GetError()); + fprintf(stderr, "Failed to create Pango setup thread: %s\n", SDL_GetError()); } else { @@ -31048,31 +29544,27 @@ static void setup(void) #ifdef FORKED_FONTS /* NOW we can fork our own font scanner stuff, and let it run in the bgkd -bjk 2010.04.27 */ DEBUG_PRINTF("Now running font scanner\n"); - run_font_scanner(screen, texture, renderer, - lang_prefixes[get_current_language()]); + run_font_scanner(screen, texture, renderer, lang_prefixes[get_current_language()]); #endif #endif medium_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, DATA_PREFIX "fonts/default_font.ttf", - (18 - - (only_uppercase * 3)) * button_scale); + (18 - (only_uppercase * 3)) * button_scale); if (medium_font == NULL) { fprintf(stderr, "\nError: Can't load font file: " DATA_PREFIX "fonts/default_font.ttf\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); } - safe_snprintf(tmp_str, sizeof(tmp_str), "Version: %s – %s", VER_VERSION, - VER_DATE); + safe_snprintf(tmp_str, sizeof(tmp_str), "Version: %s – %s", VER_VERSION, VER_DATE); tmp_surf = render_text(medium_font, tmp_str, black); dest.x = 10; @@ -31082,8 +29574,7 @@ static void setup(void) DEBUG_PRINTF("%s\n", tmp_str); - safe_snprintf(tmp_str, sizeof(tmp_str), - "© 2002–2023 Bill Kendrick, et al."); + safe_snprintf(tmp_str, sizeof(tmp_str), "© 2002–2023 Bill Kendrick, et al."); tmp_surf = render_text(medium_font, tmp_str, black); dest.x = 10; dest.y = WINDOW_HEIGHT - img_progress->h - (tmp_surf->h * 2); @@ -31103,45 +29594,28 @@ static void setup(void) #ifndef __APPLE__ - cursor_arrow = - get_cursor(arrow_bits, arrow_mask_bits, arrow_width, arrow_height, 0, 0); + cursor_arrow = get_cursor(arrow_bits, arrow_mask_bits, arrow_width, arrow_height, 0, 0); #endif - cursor_hand = - get_cursor(hand_bits, hand_mask_bits, hand_width, hand_height, 12 / scale, - 1 / scale); + cursor_hand = get_cursor(hand_bits, hand_mask_bits, hand_width, hand_height, 12 / scale, 1 / scale); - cursor_pipette = - get_cursor(pipette_bits, pipette_mask_bits, pipette_width, pipette_height, - 2 / scale, 20 / scale); + cursor_pipette = get_cursor(pipette_bits, pipette_mask_bits, pipette_width, pipette_height, 2 / scale, 20 / scale); - cursor_wand = - get_cursor(wand_bits, wand_mask_bits, wand_width, wand_height, 4 / scale, - 4 / scale); + cursor_wand = get_cursor(wand_bits, wand_mask_bits, wand_width, wand_height, 4 / scale, 4 / scale); cursor_insertion = get_cursor(insertion_bits, insertion_mask_bits, - insertion_width, insertion_height, 7 / scale, - 4 / scale); + insertion_width, insertion_height, 7 / scale, 4 / scale); - cursor_brush = - get_cursor(brush_bits, brush_mask_bits, brush_width, brush_height, - 4 / scale, 28 / scale); + cursor_brush = get_cursor(brush_bits, brush_mask_bits, brush_width, brush_height, 4 / scale, 28 / scale); cursor_crosshair = get_cursor(crosshair_bits, crosshair_mask_bits, - crosshair_width, crosshair_height, 15 / scale, - 15 / scale); + crosshair_width, crosshair_height, 15 / scale, 15 / scale); - cursor_rotate = - get_cursor(rotate_bits, rotate_mask_bits, rotate_width, rotate_height, - 15 / scale, 15 / scale); + cursor_rotate = get_cursor(rotate_bits, rotate_mask_bits, rotate_width, rotate_height, 15 / scale, 15 / scale); - cursor_up = - get_cursor(up_bits, up_mask_bits, up_width, up_height, 15 / scale, - 1 / scale); + cursor_up = get_cursor(up_bits, up_mask_bits, up_width, up_height, 15 / scale, 1 / scale); - cursor_down = - get_cursor(down_bits, down_mask_bits, down_width, down_height, 15 / scale, - 30 / scale); + cursor_down = get_cursor(down_bits, down_mask_bits, down_width, down_height, 15 / scale, 30 / scale); cursor_tiny = get_cursor(tiny_bits, tiny_mask_bits, tiny_width, tiny_height, 3, 3); /* Exactly the same in SMALL (16x16) size! */ @@ -31157,11 +29631,9 @@ static void setup(void) * the flags are unused and should be set to 0 * Using zeros for the RGB masks sets a default value, based on the depth. */ - canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height, - 24, 0, 0, 0, 0); + canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height, 24, 0, 0, 0, 0); - save_canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height, - 24, 0, 0, 0, 0); + save_canvas = SDL_CreateRGBSurface(0, canvas_width, canvas_height, 24, 0, 0, 0, 0); img_starter = NULL; @@ -31174,8 +29646,7 @@ static void setup(void) if (canvas == NULL) { fprintf(stderr, "\nError: Can't build drawing canvas!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -31190,8 +29661,7 @@ static void setup(void) exit(1); } - sim_flood_touched = - (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); + sim_flood_touched = (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h)); if (sim_flood_touched == NULL) { fprintf(stderr, "\nError: Can't build drawing touch mask for Fill!\n"); @@ -31212,8 +29682,7 @@ static void setup(void) WINDOW_WIDTH - (r_ttools.w * 2), (button_h * 7) + 40 + HEIGHTOFFSET, screen->format->BitsPerPixel, - screen->format->Rmask, screen->format->Gmask, - screen->format->Bmask, TPAINT_AMASK); + screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, TPAINT_AMASK); /* making the label layer transparent */ SDL_FillRect(label, NULL, SDL_MapRGBA(label->format, 0, 0, 0, 0)); @@ -31225,15 +29694,13 @@ static void setup(void) undo_bufs[i] = SDL_CreateRGBSurface(screen->flags, canvas_width, canvas_height, screen->format->BitsPerPixel, - screen->format->Rmask, screen->format->Gmask, - screen->format->Bmask, 0); + screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0); if (undo_bufs[i] == NULL) { fprintf(stderr, "\nError: Can't build undo buffer! (%d of %d)\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", i + 1, NUM_UNDO_BUFS, SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", i + 1, NUM_UNDO_BUFS, SDL_GetError()); cleanup(); exit(1); @@ -31252,8 +29719,7 @@ static void setup(void) img_title_on = loadimagerb(DATA_PREFIX "images/ui/title.png"); img_title_large_on = loadimagerb(DATA_PREFIX "images/ui/title_large.png"); img_title_off = loadimagerb(DATA_PREFIX "images/ui/no_title.png"); - img_title_large_off = - loadimagerb(DATA_PREFIX "images/ui/no_title_large.png"); + img_title_large_off = loadimagerb(DATA_PREFIX "images/ui/no_title_large.png"); img_btn_up = loadimagerb(DATA_PREFIX "images/ui/btn_up.png"); img_btn_down = loadimagerb(DATA_PREFIX "images/ui/btn_down.png"); @@ -31278,9 +29744,7 @@ static void setup(void) img_btn_off->w, img_btn_off->h, img_btn_off->format->BitsPerPixel, img_btn_off->format->Rmask, - img_btn_off->format->Gmask, - img_btn_off->format->Bmask, - img_btn_off->format->Amask); + img_btn_off->format->Gmask, img_btn_off->format->Bmask, img_btn_off->format->Amask); SDL_SetSurfaceAlphaMod(img_black, SDL_ALPHA_TRANSPARENT); SDL_FillRect(img_black, NULL, SDL_MapRGBA(screen->format, 0, 0, 0, 255)); @@ -31289,13 +29753,10 @@ static void setup(void) img_btn_off->w, img_btn_off->h, img_btn_off->format->BitsPerPixel, img_btn_off->format->Rmask, - img_btn_off->format->Gmask, - img_btn_off->format->Bmask, - img_btn_off->format->Amask); + img_btn_off->format->Gmask, img_btn_off->format->Bmask, img_btn_off->format->Amask); SDL_SetSurfaceAlphaMod(img_grey, SDL_ALPHA_TRANSPARENT); - SDL_FillRect(img_grey, NULL, - SDL_MapRGBA(screen->format, 0x88, 0x88, 0x88, 255)); + SDL_FillRect(img_grey, NULL, SDL_MapRGBA(screen->format, 0x88, 0x88, 0x88, 255)); show_progress_bar(screen); @@ -31333,8 +29794,7 @@ static void setup(void) img_shrink = loadimagerb(DATA_PREFIX "images/ui/shrink.png"); img_magic_paint = loadimagerb(DATA_PREFIX "images/ui/magic_paint.png"); - img_magic_fullscreen = - loadimagerb(DATA_PREFIX "images/ui/magic_fullscreen.png"); + img_magic_fullscreen = loadimagerb(DATA_PREFIX "images/ui/magic_fullscreen.png"); img_shapes_center = loadimagerb(DATA_PREFIX "images/ui/shapes_center.png"); img_shapes_corner = loadimagerb(DATA_PREFIX "images/ui/shapes_corner.png"); @@ -31365,8 +29825,7 @@ static void setup(void) img_scroll_down = loadimagerb(DATA_PREFIX "images/ui/scroll_down.png"); img_scroll_up_off = loadimagerb(DATA_PREFIX "images/ui/scroll_up_off.png"); - img_scroll_down_off = - loadimagerb(DATA_PREFIX "images/ui/scroll_down_off.png"); + img_scroll_down_off = loadimagerb(DATA_PREFIX "images/ui/scroll_down_off.png"); img_color_sel = loadimagerb(DATA_PREFIX "images/ui/csel.png"); img_color_mix = loadimagerb(DATA_PREFIX "images/ui/cmix.png"); img_color_grab = loadimagerb(DATA_PREFIX "images/ui/color_grab.png"); @@ -31394,8 +29853,7 @@ static void setup(void) img_btn_up, img_btn_down, img_btn_off, img_btn_nav, img_btn_hold, img_oskdel, img_osktab, img_oskenter, - img_oskcapslock, img_oskshift, - onscreen_keyboard_disable_change); + img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); } else { @@ -31404,8 +29862,7 @@ static void setup(void) img_btn_up, img_btn_down, img_btn_off, img_btn_nav, img_btn_hold, img_oskdel, img_osktab, img_oskenter, - img_oskcapslock, img_oskshift, - onscreen_keyboard_disable_change); + img_oskcapslock, img_oskshift, onscreen_keyboard_disable_change); } } @@ -31424,9 +29881,7 @@ static void setup(void) if (num_brushes == 0) { - fprintf(stderr, - "\nError: No brushes found in " DATA_PREFIX "brushes/\n" - "or %s\n\n", homedirdir); + fprintf(stderr, "\nError: No brushes found in " DATA_PREFIX "brushes/\n" "or %s\n\n", homedirdir); cleanup(); exit(1); } @@ -31437,30 +29892,25 @@ static void setup(void) /* Load system fonts: */ large_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, - DATA_PREFIX "fonts/default_font.ttf", - (30 - - (only_uppercase * 3)) * button_scale); + DATA_PREFIX "fonts/default_font.ttf", (30 - (only_uppercase * 3)) * button_scale); if (large_font == NULL) { fprintf(stderr, "\nError: Can't load font file: " DATA_PREFIX "fonts/default_font.ttf\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); } - small_font = - TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, - DATA_PREFIX "fonts/default_font.ttf", + small_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, DATA_PREFIX "fonts/default_font.ttf", #ifdef __APPLE__ - (12 - (only_uppercase * 2)) * button_scale + (12 - (only_uppercase * 2)) * button_scale #else - (13 - (only_uppercase * 2)) * button_scale + (13 - (only_uppercase * 2)) * button_scale #endif ); @@ -31469,8 +29919,7 @@ static void setup(void) fprintf(stderr, "\nError: Can't load font file: " DATA_PREFIX "fonts/default_font.ttf\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -31497,10 +29946,12 @@ static void setup(void) /* Load magic tool plugins: */ magic_disabled_features = 0x00000000; - if (disable_magic_sizes) { + if (disable_magic_sizes) + { magic_disabled_features |= MAGIC_FEATURE_SIZE; } - if (disable_magic_controls) { + if (disable_magic_controls) + { magic_disabled_features |= MAGIC_FEATURE_CONTROL; } @@ -31512,6 +29963,7 @@ static void setup(void) for (i = 0; i < NUM_SHAPES; i++) { SDL_Surface *aux_surf = loadimage(shape_img_fnames[i]); + img_shapes[i] = thumbnail2(aux_surf, (aux_surf->w * button_w) / ORIGINAL_BUTTON_SIZE, (aux_surf->h * button_h) / ORIGINAL_BUTTON_SIZE, 0, 1); @@ -31524,6 +29976,7 @@ static void setup(void) for (i = 0; i < NUM_FILLS; i++) { SDL_Surface *aux_surf = loadimage(fill_img_fnames[i]); + img_fills[i] = thumbnail2(aux_surf, (aux_surf->w * button_w) / ORIGINAL_BUTTON_SIZE, (aux_surf->h * button_h) / ORIGINAL_BUTTON_SIZE, 0, 1); @@ -31544,8 +29997,7 @@ static void setup(void) show_progress_bar(screen); img_color_picker = loadimagerb(DATA_PREFIX "images/ui/color_picker.png"); - img_color_picker_val = - loadimagerb(DATA_PREFIX "images/ui/color_picker_val.png"); + img_color_picker_val = loadimagerb(DATA_PREFIX "images/ui/color_picker_val.png"); /* Create toolbox and selector labels: */ @@ -31562,9 +30014,7 @@ static void setup(void) free(td_str); tmp_surf = render_text(myfont, upstr, black); free(upstr); - img_title_names[i] = - thumbnail(tmp_surf, min((int) (84 * button_scale), tmp_surf->w), - tmp_surf->h, 0); + img_title_names[i] = thumbnail(tmp_surf, min((int)(84 * button_scale), tmp_surf->w), tmp_surf->h, 0); SDL_FreeSurface(tmp_surf); } else @@ -31584,12 +30034,10 @@ static void setup(void) img_paintwell = thumbnail(img1, color_button_w, color_button_h, 0); tmp_btn_up = thumbnail(img_btn_up, color_button_w, color_button_h, 0); tmp_btn_down = thumbnail(img_btn_down, color_button_w, color_button_h, 0); - img_color_btn_off = - thumbnail(img_btn_off, color_button_w, color_button_h, 0); + img_color_btn_off = thumbnail(img_btn_off, color_button_w, color_button_h, 0); SDL_FreeSurface(img1); - img_color_picker_thumb = - thumbnail(img_color_picker, color_button_w, color_button_h, 0); + img_color_picker_thumb = thumbnail(img_color_picker, color_button_w, color_button_h, 0); /* Create surfaces to draw them into: */ @@ -31601,15 +30049,12 @@ static void setup(void) /* (WINDOW_WIDTH - r_ttoolopt.w) / NUM_COLORS, 48, */ tmp_btn_up->w, tmp_btn_up->h, screen->format->BitsPerPixel, - screen->format->Rmask, - screen->format->Gmask, - screen->format->Bmask, 0); + screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, 0); if (img_color_btns[i] == NULL) { fprintf(stderr, "\nError: Can't build color button!\n" - "The Simple DirectMedia Layer error that occurred was:\n" - "%s\n\n", SDL_GetError()); + "The Simple DirectMedia Layer error that occurred was:\n" "%s\n\n", SDL_GetError()); cleanup(); exit(1); @@ -31631,26 +30076,22 @@ static void setup(void) for (y = 0; y < tmp_btn_up->h /* 48 */ ; y++) { - for (x = 0; - x < tmp_btn_up->w /* (WINDOW_WIDTH - r_ttoolopt.w) / NUM_COLORS */ ; + for (x = 0; x < tmp_btn_up->w /* (WINDOW_WIDTH - r_ttoolopt.w) / NUM_COLORS */ ; x++) { double ru, gu, bu, rd, gd, bd, aa; Uint8 a; - SDL_GetRGB(getpixel_tmp_btn_up(tmp_btn_up, x, y), tmp_btn_up->format, - &r, &g, &b); + SDL_GetRGB(getpixel_tmp_btn_up(tmp_btn_up, x, y), tmp_btn_up->format, &r, &g, &b); ru = sRGB_to_linear_table[r]; gu = sRGB_to_linear_table[g]; bu = sRGB_to_linear_table[b]; - SDL_GetRGB(getpixel_tmp_btn_down(tmp_btn_down, x, y), - tmp_btn_down->format, &r, &g, &b); + SDL_GetRGB(getpixel_tmp_btn_down(tmp_btn_down, x, y), tmp_btn_down->format, &r, &g, &b); rd = sRGB_to_linear_table[r]; gd = sRGB_to_linear_table[g]; bd = sRGB_to_linear_table[b]; - SDL_GetRGBA(getpixel_img_paintwell(img_paintwell, x, y), - img_paintwell->format, &r, &g, &b, &a); + SDL_GetRGBA(getpixel_img_paintwell(img_paintwell, x, y), img_paintwell->format, &r, &g, &b, &a); aa = a / 255.0; for (i = 0; i < NUM_COLORS; i++) @@ -31663,13 +30104,11 @@ static void setup(void) { putpixels[img_color_btns[i]->format->BytesPerPixel] (img_color_btns[i], x, y, - getpixels[img_color_picker_thumb->format-> - BytesPerPixel] (img_color_picker_thumb, x, y)); - putpixels[img_color_btns[i + NUM_COLORS]->format-> - BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, - getpixels[img_color_picker_thumb->format-> - BytesPerPixel] - (img_color_picker_thumb, x, y)); + getpixels[img_color_picker_thumb->format->BytesPerPixel] (img_color_picker_thumb, x, y)); + putpixels[img_color_btns[i + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, + getpixels[img_color_picker_thumb-> + format->BytesPerPixel] + (img_color_picker_thumb, x, y)); } if (i < COLOR_PICKER || a == 255) @@ -31678,21 +30117,19 @@ static void setup(void) (img_color_btns[i], x, y, SDL_MapRGB(img_color_btns[i]->format, linear_to_sRGB(rh * aa + ru * (1.0 - aa)), - linear_to_sRGB(gh * aa + gu * (1.0 - aa)), - linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); - putpixels[img_color_btns[i + NUM_COLORS]->format-> - BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, - SDL_MapRGB(img_color_btns - [i + NUM_COLORS]->format, - linear_to_sRGB(rh * aa + - rd * (1.0 - - aa)), - linear_to_sRGB(gh * aa + - gd * (1.0 - - aa)), - linear_to_sRGB(bh * aa + - bd * (1.0 - - aa)))); + linear_to_sRGB(gh * aa + gu * (1.0 - aa)), linear_to_sRGB(bh * aa + bu * (1.0 - aa)))); + putpixels[img_color_btns[i + NUM_COLORS]->format->BytesPerPixel] (img_color_btns[i + NUM_COLORS], x, y, + SDL_MapRGB(img_color_btns + [i + NUM_COLORS]->format, + linear_to_sRGB(rh * aa + + rd * (1.0 - + aa)), + linear_to_sRGB(gh * aa + + gd * (1.0 - + aa)), + linear_to_sRGB(bh * aa + + bd * (1.0 - + aa)))); } } } @@ -31734,8 +30171,10 @@ static void setup(void) and we word-wrapped it to be two lines tall */ /* (Tools) */ - for (i = 0; i < NUM_TOOLS; i++) { - if (img_tools[i]->h + img_tool_names[i]->h > button_h - 1) { + for (i = 0; i < NUM_TOOLS; i++) + { + if (img_tools[i]->h + img_tool_names[i]->h > button_h - 1) + { tmp_surf = thumbnail(img_tools[i], img_tools[i]->w, (button_h - img_tool_names[i]->h - 1), 0); SDL_FreeSurface(img_tools[i]); img_tools[i] = tmp_surf; @@ -31743,10 +30182,14 @@ static void setup(void) } /* (Magic tools) */ - for (i = 0; i < MAX_MAGIC_GROUPS; i++) { - for (j = 0; j < num_magics[i]; j++) { - if (magics[i][j].img_icon->h + magics[i][j].img_name->h > button_h - 1) { - tmp_surf = thumbnail(magics[i][j].img_icon, magics[i][j].img_icon->w, (button_h - magics[i][j].img_name->h - 1), 0); + for (i = 0; i < MAX_MAGIC_GROUPS; i++) + { + for (j = 0; j < num_magics[i]; j++) + { + if (magics[i][j].img_icon->h + magics[i][j].img_name->h > button_h - 1) + { + tmp_surf = + thumbnail(magics[i][j].img_icon, magics[i][j].img_icon->w, (button_h - magics[i][j].img_name->h - 1), 0); SDL_FreeSurface(magics[i][j].img_icon); magics[i][j].img_icon = tmp_surf; } @@ -31754,8 +30197,10 @@ static void setup(void) } /* (Shapes) */ - for (i = 0; i < NUM_SHAPES; i++) { - if (img_shapes[i]->h + img_shape_names[i]->h > button_h - 1) { + for (i = 0; i < NUM_SHAPES; i++) + { + if (img_shapes[i]->h + img_shape_names[i]->h > button_h - 1) + { tmp_surf = thumbnail(img_shapes[i], img_shapes[i]->w, (button_h - img_shape_names[i]->h - 1), 0); SDL_FreeSurface(img_shapes[i]); img_shapes[i] = tmp_surf; @@ -31763,8 +30208,10 @@ static void setup(void) } /* (Fill methods) */ - for (i = 0; i < NUM_FILLS; i++) { - if (img_fills[i]->h + img_fill_names[i]->h > button_h - 1) { + for (i = 0; i < NUM_FILLS; i++) + { + if (img_fills[i]->h + img_fill_names[i]->h > button_h - 1) + { tmp_surf = thumbnail(img_fills[i], img_fills[i]->w, (button_h - img_fill_names[i]->h - 1), 0); SDL_FreeSurface(img_fills[i]); img_fills[i] = tmp_surf; @@ -31822,9 +30269,7 @@ static void claim_to_be_ready(void) src.w = img_title->w; src.x = 0; src.y = img_title->h - img_progress->h; - dest.x = - ((WINDOW_WIDTH - img_title->w - (img_title_tuxpaint->w / 2)) / 2) + - (img_title_tuxpaint->w / 2) + 20; + dest.x = ((WINDOW_WIDTH - img_title->w - (img_title_tuxpaint->w / 2)) / 2) + (img_title_tuxpaint->w / 2) + 20; SDL_BlitSurface(img_title, &src, screen, &dest); SDL_FreeSurface(img_title); @@ -31910,8 +30355,7 @@ static void claim_to_be_ready(void) draw_toolbar(); draw_colors(COLORSEL_FORCE_REDRAW); draw_brushes(); - update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, - (48 * 7) + 40 + HEIGHTOFFSET); + update_canvas(0, 0, WINDOW_WIDTH - r_ttoolopt.w, (48 * 7) + 40 + HEIGHTOFFSET); SDL_Flip(screen); @@ -31930,7 +30374,7 @@ int main(int argc, char *argv[]) CLOCK_TYPE time2; #endif - (void) argc; + (void)argc; #ifdef DEBUG CLOCK_ASM(time1); @@ -31963,6 +30407,7 @@ int main(int argc, char *argv[]) #ifdef WIN32 #ifndef DEBUG char stdout_win32[255], stderr_win32[255]; + safe_snprintf(stdout_win32, 255, "%s/stdout.txt", savedir); safe_snprintf(stderr_win32, 255, "%s/stderr.txt", savedir); freopen(stdout_win32, "w", stdout); /* redirect stdout to a file */ @@ -31979,13 +30424,13 @@ int main(int argc, char *argv[]) * file may not exist on the runtime system, however, so we copy the file * into our app bundle at compile time, and tell Fontconfig here to look for * the file within the app bundle. */ - putenv((char *) "FONTCONFIG_PATH=Resources/etc"); + putenv((char *)"FONTCONFIG_PATH=Resources/etc"); #endif #if defined(FC_DEBUG) /* - * Enable fontconfig debugging. See "debug.h" - */ + * Enable fontconfig debugging. See "debug.h" + */ mysetenv("FC_DEBUG", FC_DEBUG); #endif @@ -31994,8 +30439,7 @@ int main(int argc, char *argv[]) #ifdef NO_SDLPANGO /* Only fork it now if we're not planning on creating a thread to handle fontconfig stuff -bjk 2010.04.27 */ DEBUG_PRINTF("Running font scanner\n"); - run_font_scanner(screen, texture, renderer, - lang_prefixes[get_current_language()]); + run_font_scanner(screen, texture, renderer, lang_prefixes[get_current_language()]); #else DEBUG_PRINTF("NOT running font scanner\n"); #endif @@ -32008,8 +30452,7 @@ int main(int argc, char *argv[]) } if (disable_save && (promptless_save != SAVE_OVER_UNSET)) { - fprintf(stderr, - "Warning: Save-over option specified, but saving is disabled.\n"); + fprintf(stderr, "Warning: Save-over option specified, but saving is disabled.\n"); } if (promptless_save == SAVE_OVER_UNSET) @@ -32020,32 +30463,33 @@ int main(int argc, char *argv[]) /* Set up! */ setup(); - DEBUG_PRINTF("Seconds in early start-up: %.3f\n", - (double) (time2 - time1) / CLOCK_SPEED); - DEBUG_PRINTF("Seconds in late start-up: %.3f\n", - (double) (time2 - time1) / CLOCK_SPEED); + DEBUG_PRINTF("Seconds in early start-up: %.3f\n", (double)(time2 - time1) / CLOCK_SPEED); + DEBUG_PRINTF("Seconds in late start-up: %.3f\n", (double)(time2 - time1) / CLOCK_SPEED); #if defined(DEBUG) && !defined(NO_SDLPANGO) /* Confirm pango's character set */ - if(1) { - const char* charset; + if (1) + { + const char *charset; g_get_charset(&charset); printf("pango charset: %s\n", charset); } /* Display fonts available to pango */ - if(1) { - PangoFontMap* fontmap; - PangoFontFamily** families; + if (1) + { + PangoFontMap *fontmap; + PangoFontFamily **families; int n_families; fontmap = pango_ft2_font_map_new(); pango_font_map_list_families(fontmap, &families, &n_families); - for(int i=0; i < n_families; i++) { - const char* family_name = pango_font_family_get_name(families[i]); + for (int i = 0; i < n_families; i++) + { + const char *family_name = pango_font_family_get_name(families[i]); printf("pango ft2 fontmap[%d] = '%s'\n", i, family_name); } @@ -32078,8 +30522,7 @@ static int trash(char *path) #elif defined(__APPLE__) return apple_trash(path); #else - char fname[MAX_PATH], trashpath[MAX_PATH], dest[MAX_PATH], - infoname[MAX_PATH], bname[MAX_PATH], ext[MAX_PATH]; + char fname[MAX_PATH], trashpath[MAX_PATH], dest[MAX_PATH], infoname[MAX_PATH], bname[MAX_PATH], ext[MAX_PATH]; char deldate[32]; struct tm tim; time_t now; @@ -32099,7 +30542,7 @@ static int trash(char *path) return (unlink(path)); } - DEBUG_PRINTF("trash: basename=%s", basename(path)); /* EP */ + DEBUG_PRINTF("trash: basename=%s", basename(path)); /* EP */ safe_strncpy(fname, basename(path), sizeof(fname)); if (!file_exists(path)) @@ -32114,13 +30557,11 @@ static int trash(char *path) /* FIXME: Use xdg function */ if (getenv("XDG_DATA_HOME") != NULL) { - safe_snprintf(trashpath, sizeof(trashpath), "%s/Trash", - getenv("XDG_DATA_HOME")); + safe_snprintf(trashpath, sizeof(trashpath), "%s/Trash", getenv("XDG_DATA_HOME")); } else if (getenv("HOME") != NULL) { - safe_snprintf(trashpath, sizeof(trashpath), "%s/.local/share/Trash", - getenv("HOME")); + safe_snprintf(trashpath, sizeof(trashpath), "%s/.local/share/Trash", getenv("HOME")); } else { @@ -32148,8 +30589,7 @@ static int trash(char *path) return (unlink(path)); } - safe_snprintf(infoname, sizeof(infoname), "%s/info/%s.trashinfo", trashpath, - fname); + safe_snprintf(infoname, sizeof(infoname), "%s/info/%s.trashinfo", trashpath, fname); cnt = 1; while (file_exists(dest) && cnt < 100) @@ -32157,8 +30597,7 @@ static int trash(char *path) safe_snprintf(fname, sizeof(fname), "%s_%d.%s", bname, cnt, ext); safe_snprintf(dest, sizeof(dest), "%s/files/%s", trashpath, fname); - safe_snprintf(infoname, sizeof(infoname), "%s/info/%s.trashinfo", - trashpath, fname); + safe_snprintf(infoname, sizeof(infoname), "%s/info/%s.trashinfo", trashpath, fname); cnt++; } @@ -32229,7 +30668,7 @@ static int trash(char *path) /* FIXME: Is this sufficient to find 'dbus-send' (rely on system to use $PATH?) -bjk 2011.04.18 */ tmp = system("dbus-send / org.kde.KDirNotify.FilesAdded string:trash:/"); - (void) tmp; + (void)tmp; /* Note: GNOME figures out when things change because it asks the Kernel @@ -32262,8 +30701,7 @@ int file_exists(char *path) */ /* Don't move the mouse here as this is only called when an event triggers it and the joystick can be holded withouth sending any event. */ -static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, - int *val_y) +static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, int *val_y) { int i, j, step; @@ -32282,20 +30720,16 @@ static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, else { if (i > joystick_low_threshold) - *val_x = - min((i - joystick_low_threshold) / step + 1, joystick_maxsteps); + *val_x = min((i - joystick_low_threshold) / step + 1, joystick_maxsteps); else if (i < -joystick_low_threshold) - *val_x = - max((i + joystick_low_threshold) / step - 1, -joystick_maxsteps); + *val_x = max((i + joystick_low_threshold) / step - 1, -joystick_maxsteps); else *val_x = 0; if (j > joystick_low_threshold) - *val_y = - min((j - joystick_low_threshold) / step + 1, joystick_maxsteps); + *val_y = min((j - joystick_low_threshold) / step + 1, joystick_maxsteps); else if (j < -joystick_low_threshold) - *val_y = - max((j + joystick_low_threshold) / step - 1, -joystick_maxsteps); + *val_y = max((j + joystick_low_threshold) / step - 1, -joystick_maxsteps); else *val_y = 0; @@ -32312,8 +30746,7 @@ static void handle_joyaxismotion(SDL_Event event, int *motioner, int *val_x, * FIXME */ static void handle_joyhatmotion(SDL_Event event, int oldpos_x, int oldpos_y, - int *valhat_x, int *valhat_y, - int *hatmotioner, Uint32 * old_hat_ticks) + int *valhat_x, int *valhat_y, int *hatmotioner, Uint32 * old_hat_ticks) { *hatmotioner = 1; @@ -32382,8 +30815,7 @@ static void handle_joyballmotion(SDL_Event event, int oldpos_x, int oldpos_y) * FIXME */ static void handle_motioners(int oldpos_x, int oldpos_y, int motioner, - int hatmotioner, int old_hat_ticks, int val_x, - int val_y, int valhat_x, int valhat_y) + int hatmotioner, int old_hat_ticks, int val_x, int val_y, int valhat_x, int valhat_y) { int vx, vy; Uint32 ticks; @@ -32413,8 +30845,7 @@ static void handle_motioners(int oldpos_x, int oldpos_y, int motioner, /** * FIXME */ -static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, - int oldpos_y) +static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, int oldpos_y) { handle_joybuttonupdownscl(event, oldpos_x, oldpos_y, r_tools); } @@ -32422,8 +30853,7 @@ static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, /** * FIXME */ -static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, - int oldpos_y, SDL_Rect real_r_tools) +static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools) { int i, ignore = 0; int eby, ts; @@ -32511,64 +30941,55 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, if (event.button.button == joystick_button_selectbrushtool) { ev.button.x = (TOOL_BRUSH % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_BRUSH / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_BRUSH / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectstamptool) { ev.button.x = (TOOL_STAMP % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_STAMP / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_STAMP / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectlinestool) { ev.button.x = (TOOL_LINES % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_LINES / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_LINES / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectshapestool) { ev.button.x = (TOOL_SHAPES % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_SHAPES / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_SHAPES / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selecttexttool) { ev.button.x = (TOOL_TEXT % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_TEXT / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_TEXT / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectlabeltool) { ev.button.x = (TOOL_LABEL % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_LABEL / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_LABEL / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectfilltool) { ev.button.x = (TOOL_FILL % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_FILL / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_FILL / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selectmagictool) { ev.button.x = (TOOL_MAGIC % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_MAGIC / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_MAGIC / 2 * button_h + button_h / 2; } else if (event.button.button == joystick_button_selecterasertool) { ev.button.x = (TOOL_ERASER % 2) * button_w + button_w / 2; - ev.button.y = - real_r_tools.y + TOOL_ERASER / 2 * button_h + button_h / 2; + ev.button.y = real_r_tools.y + TOOL_ERASER / 2 * button_h + button_h / 2; } /* Deal with scroll to reveal the button that should be clicked */ @@ -32637,8 +31058,7 @@ static void start_motion_convert(SDL_Event event) else if (HIT(r_toolopt) && (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP || cur_tool == TOOL_LINES || cur_tool == TOOL_SHAPES - || cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL - || cur_tool == TOOL_MAGIC)) + || cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL || cur_tool == TOOL_MAGIC)) scroll = 1; else if ((cur_tool == TOOL_OPEN) && HIT(r_canvas)) scroll = 1; @@ -32680,8 +31100,7 @@ static void convert_motion_to_wheel(SDL_Event event) else if (HIT(r_toolopt) && (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP || cur_tool == TOOL_LINES || cur_tool == TOOL_SHAPES - || cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL - || cur_tool == TOOL_MAGIC)) + || cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL || cur_tool == TOOL_MAGIC)) { scroll = 1; high = 48; @@ -32734,8 +31153,7 @@ char *get_xdg_user_dir(const char *dir_type, const char *fallback) { FILE *fi; char *config_home, *found; - char tmp_path[MAX_PATH], config_path[MAX_PATH], line[MAX_PATH], - search[MAX_PATH], return_path[MAX_PATH]; + char tmp_path[MAX_PATH], config_path[MAX_PATH], line[MAX_PATH], search[MAX_PATH], return_path[MAX_PATH]; int found_it; found_it = FALSE; @@ -32758,8 +31176,7 @@ char *get_xdg_user_dir(const char *dir_type, const char *fallback) else { #ifdef DEBUG - fprintf(stderr, - "No HOME, either?! Returing fallback in current directory\n"); + fprintf(stderr, "No HOME, either?! Returing fallback in current directory\n"); #endif return strdup(fallback); } @@ -32805,8 +31222,7 @@ char *get_xdg_user_dir(const char *dir_type, const char *fallback) #endif if (strstr(found, "$HOME/") == found) { - safe_snprintf(return_path, MAX_PATH, "%s/%s", getenv("HOME"), - found + 6 /* skip '$HOME/' */ ); + safe_snprintf(return_path, MAX_PATH, "%s/%s", getenv("HOME"), found + 6 /* skip '$HOME/' */ ); } else { @@ -32856,8 +31272,7 @@ char *get_xdg_user_dir(const char *dir_type, const char *fallback) * @param int speed -- how fast to play the slideshow (0 and 1 both = slowest, 10 = fasted) * @return int -- 0 if export failed or was aborted, 1 if successful */ -static int export_gif(int *selected, int num_selected, char *dirname, - char **d_names, char **d_exts, int speed) +static int export_gif(int *selected, int num_selected, char *dirname, char **d_names, char **d_exts, int speed) { char *tmp_starter_id, *tmp_template_id, *tmp_file_id; int tmp_starter_mirrored, tmp_starter_flipped, tmp_starter_personal; @@ -32874,6 +31289,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, liq_attr *liq_handle; liq_image *input_image; liq_result *quantization_result; + #if LIQ_VERSION >= 20800 liq_error qtiz_status; #endif @@ -32923,8 +31339,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, /* Figure out filename: */ - safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname, d_names[which], - d_exts[which]); + safe_snprintf(fname, sizeof(fname), "%s/%s%s", dirname, d_names[which], d_exts[which]); /* Load and scale the image */ img = myIMG_Load(fname); @@ -32963,8 +31378,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, { for (x = 0; x < overall_w; x++) { - SDL_GetRGBA(getpixels[screen->format->BytesPerPixel] (screen, x, y), - screen->format, &r, &g, &b, &a); + SDL_GetRGBA(getpixels[screen->format->BytesPerPixel] (screen, x, y), screen->format, &r, &g, &b, &a); bitmap[((i * overall_area) + (y * overall_w) + x) * 4 + 0] = r; bitmap[((i * overall_area) + (y * overall_w) + x) * 4 + 1] = g; @@ -32982,17 +31396,14 @@ static int export_gif(int *selected, int num_selected, char *dirname, { /* Quantize to max 256 (8bpp) colors and generate a suitable palette */ liq_handle = liq_attr_create(); - input_image = - liq_image_create_rgba(liq_handle, bitmap, overall_w, - num_selected * overall_h, 0); + input_image = liq_image_create_rgba(liq_handle, bitmap, overall_w, num_selected * overall_h, 0); liq_set_max_colors(liq_handle, 256); show_progress_bar(screen); done = export_gif_monitor_events(); #if LIQ_VERSION >= 20800 - qtiz_status = - liq_image_quantize(input_image, liq_handle, &quantization_result); + qtiz_status = liq_image_quantize(input_image, liq_handle, &quantization_result); done = (qtiz_status != LIQ_OK); #else quantization_result = liq_quantize_image(liq_handle, input_image); @@ -33005,12 +31416,11 @@ static int export_gif(int *selected, int num_selected, char *dirname, raw_8bit_pixels = malloc(pixels_size); liq_set_dithering_level(quantization_result, 1.0); - liq_write_remapped_image(quantization_result, input_image, - raw_8bit_pixels, pixels_size); + liq_write_remapped_image(quantization_result, input_image, raw_8bit_pixels, pixels_size); palette = liq_get_palette(quantization_result); free(bitmap); - for (j = 0; j < (int) palette->count; j++) + for (j = 0; j < (int)palette->count; j++) { gif_palette[j * 3 + 0] = palette->entries[j].r; gif_palette[j * 3 + 1] = palette->entries[j].g; @@ -33028,8 +31438,7 @@ static int export_gif(int *selected, int num_selected, char *dirname, /* Export each frame */ for (i = 0; i < num_selected && !done; i++) { - memcpy(gif->frame, raw_8bit_pixels + i * overall_area, - overall_area); + memcpy(gif->frame, raw_8bit_pixels + i * overall_area, overall_area); ge_add_frame(gif, gif_speed); show_progress_bar(screen); @@ -33157,8 +31566,7 @@ static int export_pict(char *fname) if (fo == NULL) { fprintf(stderr, - "Cannot export to new file '%s'\nThe error that occurred was:\n%s\n\n", - pict_fname, strerror(errno)); + "Cannot export to new file '%s'\nThe error that occurred was:\n%s\n\n", pict_fname, strerror(errno)); free(pict_fname); fclose(fi); return FALSE; @@ -33216,17 +31624,12 @@ static char *get_export_filepath(const char *ext) /* Make sure the export dir exists */ - if (!make_directory - (DIR_EXPORT, "", - "Can't create export directory; will try to make its parent (E016)")) + if (!make_directory(DIR_EXPORT, "", "Can't create export directory; will try to make its parent (E016)")) { /* See if perhaps we need to try and make its parent directory first? */ - if (make_directory - (DIR_EXPORT_PARENT, "", - "Can't create export directory parent (E016b)")) + if (make_directory(DIR_EXPORT_PARENT, "", "Can't create export directory parent (E016b)")) { - if (!make_directory - (DIR_EXPORT, "", "Can't create export directory (E016c)")) + if (!make_directory(DIR_EXPORT, "", "Can't create export directory (E016c)")) { return NULL; } @@ -33250,6 +31653,7 @@ static char *get_export_filepath(const char *ext) char *safe_strncat(char *dest, const char *src, size_t n) { char *ptr; + ptr = strncat(dest, src, n - 1); dest[n - 1] = '\0'; return ptr; @@ -33258,6 +31662,7 @@ char *safe_strncat(char *dest, const char *src, size_t n) char *safe_strncpy(char *dest, const char *src, size_t n) { char *ptr; + ptr = strncpy(dest, src, n - 1); /* FIXME: Clean up, and keep safe, to avoid compiler warning (e.g., "output may be truncated copying 255 bytes from a string of length 255") */ dest[n - 1] = '\0'; return ptr; @@ -33290,8 +31695,7 @@ static void sloppy_frac(float f, int *numer, int *denom) for (n = 1; n < d; n++) { n_over_d_100 = ((n * 100) / d); - if (n_over_d_100 >= fr && - n_over_d_100 < (fr + ((SLOPPY_FRAC_MIN * 100) / SLOPPY_FRAC_MAX))) + if (n_over_d_100 >= fr && n_over_d_100 < (fr + ((SLOPPY_FRAC_MIN * 100) / SLOPPY_FRAC_MAX))) { *numer = n; *denom = d; @@ -33426,8 +31830,7 @@ static void apply_label_node(int old_x, int old_y) rect.w = label_node_to_edit->save_width; rect.h = label_node_to_edit->save_height; - SDL_BlitSurface(label_node_to_edit->label_node_surface, NULL, canvas, - &rect); + SDL_BlitSurface(label_node_to_edit->label_node_surface, NULL, canvas, &rect); label_node_to_edit->is_enabled = FALSE; /* [Best way to explain this?] */ @@ -33495,7 +31898,8 @@ static void reposition_onscreen_keyboard(int y) * * @return int */ -int calc_magic_control_rows(void) { +int calc_magic_control_rows(void) +{ int r; /* Start with group changing (left/right) buttons */ @@ -33511,4 +31915,3 @@ int calc_magic_control_rows(void) { return r; } - diff --git a/src/win32_dirent.c b/src/win32_dirent.c index 0f05d56f4..daaae4b59 100644 --- a/src/win32_dirent.c +++ b/src/win32_dirent.c @@ -84,7 +84,7 @@ struct dirent *readdir(struct DIR *pDir) if (pDir->hFind) { - strcpy(pDir->de.d_name, (const char *) pDir->wfd.cFileName); + strcpy(pDir->de.d_name, (const char *)pDir->wfd.cFileName); if (!FindNextFile(pDir->hFind, &pDir->wfd)) { @@ -107,9 +107,7 @@ struct dirent *readdir(struct DIR *pDir) */ int alphasort(const void *a, const void *b) { - return (strcmp - ((*(const struct dirent **) a)->d_name, - (*(const struct dirent **) b)->d_name)); + return (strcmp((*(const struct dirent **)a)->d_name, (*(const struct dirent **)b)->d_name)); } /** @@ -126,15 +124,11 @@ static int addToList(int i, struct dirent ***namelist, struct dirent *entry) int size; struct dirent *block; - *namelist = - (struct dirent **) realloc((void *) (*namelist), - (size_t) ((i + 1) * sizeof(struct dirent *))); + *namelist = (struct dirent **)realloc((void *)(*namelist), (size_t)((i + 1) * sizeof(struct dirent *))); if (*namelist == NULL) return -1; - size = - (((char *) &entry->d_name) - ((char *) entry)) + strlen(entry->d_name) + - 1; - block = (struct dirent *) malloc(size); + size = (((char *)&entry->d_name) - ((char *)entry)) + strlen(entry->d_name) + 1; + block = (struct dirent *)malloc(size); if (block == NULL) return -1; (*namelist)[i] = block; @@ -151,8 +145,7 @@ static int addToList(int i, struct dirent ***namelist, struct dirent *entry) * @param compar Callback for sorting items in the list (via qsort()). * @return Count of items, or -1 on error. */ -int scandir(const char *dir, struct dirent ***namelist, selectCB select, - comparCB compar) +int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar) { DIR *pDir; int count; @@ -173,7 +166,6 @@ int scandir(const char *dir, struct dirent ***namelist, selectCB select, if (count <= 0) return -1; if (compar != NULL) - qsort((void *) (*namelist), (size_t) count, sizeof(struct dirent *), - compar); + qsort((void *)(*namelist), (size_t)count, sizeof(struct dirent *), compar); return count; } diff --git a/src/win32_dirent.h b/src/win32_dirent.h index cc77bb829..5f32dab0c 100644 --- a/src/win32_dirent.h +++ b/src/win32_dirent.h @@ -71,5 +71,4 @@ extern struct dirent *readdir(struct DIR *pDir); typedef int (*selectCB)(const struct dirent *); typedef int (*comparCB)(const void *, const void *); extern int alphasort(const void *a, const void *b); -extern int scandir(const char *dir, struct dirent ***namelist, - selectCB select, comparCB compar); +extern int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar); diff --git a/src/win32_print.c b/src/win32_print.c index 95fea9336..b206d4899 100644 --- a/src/win32_print.c +++ b/src/win32_print.c @@ -68,8 +68,7 @@ static SDL_Surface *make24bitDIB(SDL_Surface * surf) surf24 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE); surfDIB = SDL_CreateRGBSurface(SDL_SWSURFACE, surf24->w, surf24->h, 24, - pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask, - pixfmt.Amask); + pixfmt.Rmask, pixfmt.Gmask, pixfmt.Bmask, pixfmt.Amask); linesize = surf24->w * 3; // Flip top2bottom dst = surfDIB->pixels; @@ -105,8 +104,7 @@ static int GetDefaultPrinterStrings(char *device, char *driver, char *output) return 0; if (((dev = strtok(buff, ",")) != NULL) && - ((drv = strtok(NULL, ", ")) != NULL) - && ((out = strtok(NULL, ", ")) != NULL)) + ((drv = strtok(NULL, ", ")) != NULL) && ((out = strtok(NULL, ", ")) != NULL)) { if (device) strcpy(device, dev); @@ -145,8 +143,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath) if (!OpenPrinter(device, &hPrinter, NULL)) goto err_exit; - sizeof_devmode = - (int) DocumentProperties(hWnd, hPrinter, device, NULL, NULL, 0); + sizeof_devmode = (int)DocumentProperties(hWnd, hPrinter, device, NULL, NULL, 0); if (!sizeof_devmode) goto err_exit; @@ -159,8 +156,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath) if (!devmode) goto err_exit; - res = - DocumentProperties(hWnd, hPrinter, device, devmode, NULL, DM_OUT_BUFFER); + res = DocumentProperties(hWnd, hPrinter, device, devmode, NULL, DM_OUT_BUFFER); if (res != IDOK) goto err_exit; @@ -170,9 +166,7 @@ static HANDLE LoadCustomPrinterHDEVMODE(HWND hWnd, const char *filepath) goto err_exit; fclose(fp); - res = - DocumentProperties(hWnd, hPrinter, device, devmode, devmode, - DM_IN_BUFFER | DM_OUT_BUFFER); + res = DocumentProperties(hWnd, hPrinter, device, devmode, devmode, DM_IN_BUFFER | DM_OUT_BUFFER); if (res != IDOK) goto err_exit; @@ -195,8 +189,7 @@ err_exit: /** * FIXME */ -static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, - HANDLE hDevMode) +static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, HANDLE hDevMode) { FILE *fp = NULL; @@ -208,7 +201,7 @@ static int SaveCustomPrinterHDEVMODE(HWND hWnd, const char *filepath, int block_written; char devname[dmDeviceNameSize]; - strcpy(devname, (const char *) devmode->dmDeviceName); + strcpy(devname, (const char *)devmode->dmDeviceName); fwrite(devname, 1, sizeof(devname), fp); block_written = fwrite(devmode, 1, block_size, fp); GlobalUnlock(hDevMode); @@ -272,8 +265,7 @@ static int GetCustomPrinterDC(HWND hWnd, const char *printcfg, int show) { DEVMODE *devmode = (DEVMODE *) GlobalLock(pd.hDevMode); - hDCprinter = - CreateDC(NULL, (const char *) devmode->dmDeviceName, NULL, devmode); + hDCprinter = CreateDC(NULL, (const char *)devmode->dmDeviceName, NULL, devmode); GlobalUnlock(pd.hDevMode); GlobalFree(pd.hDevMode); } @@ -326,8 +318,7 @@ int IsPrinterAvailable(void) /** * FIXME */ -const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, - const char *printcfg, int showdialog) +const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, const char *printcfg, int showdialog) { const char *res = NULL; HWND hWnd; @@ -424,17 +415,17 @@ const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, if (width < pageWidth && height < pageHeight) { - float dW = (float) pageWidth / width; - float dH = (float) pageHeight / height; + float dW = (float)pageWidth / width; + float dH = (float)pageHeight / height; if (dW < dH) { width = pageWidth; - height = (int) ((height * dW * (sY / sX)) + 0.5f); + height = (int)((height * dW * (sY / sX)) + 0.5f); } else { - width = (int) ((width * dH * (sX / sY)) + 0.5f); + width = (int)((width * dH * (sX / sY)) + 0.5f); height = pageHeight; } } @@ -476,9 +467,8 @@ const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, nError = StretchDIBits(hDCprinter, rcDst.left, rcDst.top, rcDst.right - rcDst.left, rcDst.bottom - rcDst.top, - 0, 0, bmih.biWidth, bmih.biHeight, - surf24->pixels, &bmi, DIB_RGB_COLORS, SRCCOPY); - if (nError == (int) GDI_ERROR) + 0, 0, bmih.biWidth, bmih.biHeight, surf24->pixels, &bmi, DIB_RGB_COLORS, SRCCOPY); + if (nError == (int)GDI_ERROR) { res = "win32_print: StretchDIBits() failed."; goto error; @@ -523,8 +513,7 @@ error: /* Read access to Windows Registry */ -static HRESULT ReadRegistry(const char *key, const char *option, char *value, - int size) +static HRESULT ReadRegistry(const char *key, const char *option, char *value, int size) { LONG res; HKEY hKey = NULL; @@ -573,8 +562,7 @@ char *GetDefaultSaveDir(const char *suffix) { char prefix[MAX_PATH]; char path[2 * MAX_PATH]; - const char *key = - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; const char *option = "AppData"; HRESULT hr = S_OK; @@ -598,8 +586,7 @@ char *GetDefaultSaveDir(const char *suffix) char *GetSystemFontDir(void) { char path[MAX_PATH]; - const char *key = - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; const char *option = "Fonts"; HRESULT hr = S_OK; @@ -621,8 +608,7 @@ char *GetUserImageDir(void); char *GetUserImageDir(void) { char path[MAX_PATH]; - const char *key = - "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; + const char *key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; const char *option = "My Pictures"; HRESULT hr = S_OK; @@ -675,8 +661,7 @@ static int g_bWindowActive = 0; /** * FIXME */ -LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, - LPARAM lParam); +LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { int bEatKeystroke = 0; @@ -690,8 +675,7 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN: case WM_KEYUP: { - bEatKeystroke = g_bWindowActive && ((p->vkCode == VK_LWIN) - || (p->vkCode == VK_RWIN)); + bEatKeystroke = g_bWindowActive && ((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)); break; } } @@ -708,9 +692,7 @@ int InstallKeyboardHook(void) { if (g_hKeyboardHook) return -1; - g_hKeyboardHook = - SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, - GetModuleHandle(NULL), 0); + g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0); return g_hKeyboardHook ? 0 : -2; } diff --git a/src/win32_print.h b/src/win32_print.h index f24fd935c..5d1dd57a6 100644 --- a/src/win32_print.h +++ b/src/win32_print.h @@ -15,8 +15,7 @@ #endif /* if printcfg is NULL, uses the default printer */ -extern const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, - const char *printcfg, int showdialog); +extern const char *SurfacePrint(SDL_Window * window, SDL_Surface * surf, const char *printcfg, int showdialog); extern int IsPrinterAvailable(void); /* additional windows functions requiring */ diff --git a/src/win32_trash.c b/src/win32_trash.c index 5655a0011..f1d16d3cd 100644 --- a/src/win32_trash.c +++ b/src/win32_trash.c @@ -19,8 +19,7 @@ int MoveFileToRecycleBin(const TCHAR * fullPathName) fileOp.hwnd = NULL; fileOp.wFunc = FO_DELETE; fileOp.pTo = NULL; - fileOp.fFlags = - FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; + fileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT | FOF_ALLOWUNDO; return SHFileOperation(&fileOp); }