diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index ee29b7967..dc91465b8 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -194,6 +194,11 @@ https://tuxpaint.org/ Closes https://sourceforge.net/p/tuxpaint/bugs/259/ Bill Kendrick + * Magic tools with very long filenames/function names did not load + on some Android systems. Affected new Kaleido-* tools, but also + Blocks, Chalk, and Drip (hence this being listed as a bug fix). + h/t Pere for discovering this. + * SDL1.2 supported "SDL_VIDEO_WINDOW_POS" environment variable, but SDL2 does not; so reimplemented it ourselves. (See ENVARS docs.) Bill Kendrick diff --git a/magic/src/blocks_chalk_drip.c b/magic/src/blocks_etc.c similarity index 80% rename from magic/src/blocks_chalk_drip.c rename to magic/src/blocks_etc.c index e0357b9f1..f1a0f1fe7 100644 --- a/magic/src/blocks_chalk_drip.c +++ b/magic/src/blocks_etc.c @@ -1,5 +1,5 @@ /* - blocks_chalk_drip.c + blocks_etc.c Blocks, Chalk and Drip Magic Tools Plugin Tux Paint - A simple drawing program for children. @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: February 12, 2023 + Last updated: March 19, 2023 */ #include @@ -52,38 +52,38 @@ static Mix_Chunk *snd_effect[NUM_TOOLS]; /* Our function prototypes: */ -int blocks_chalk_drip_init(magic_api * api); -Uint32 blocks_chalk_drip_api_version(void); -int blocks_chalk_drip_get_tool_count(magic_api * api); -SDL_Surface *blocks_chalk_drip_get_icon(magic_api * api, int which); -char *blocks_chalk_drip_get_name(magic_api * api, int which); -int blocks_chalk_drip_get_group(magic_api * api, int which); -char *blocks_chalk_drip_get_description(magic_api * api, int which, int mode); -static void blocks_chalk_drip_linecb(void *ptr, int which, +int blocks_etc_init(magic_api * api); +Uint32 blocks_etc_api_version(void); +int blocks_etc_get_tool_count(magic_api * api); +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); -void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas, +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); -void blocks_chalk_drip_click(magic_api * api, int which, int mode, +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); -void blocks_chalk_drip_release(magic_api * api, int which, +void blocks_etc_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); -void blocks_chalk_drip_shutdown(magic_api * api); -void blocks_chalk_drip_set_color(magic_api * api, int which, SDL_Surface * canvas, +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); -int blocks_chalk_drip_requires_colors(magic_api * api, int which); -void blocks_chalk_drip_switchin(magic_api * api, int which, int mode, +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_chalk_drip_switchout(magic_api * api, int which, int mode, +void blocks_etc_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); -int blocks_chalk_drip_modes(magic_api * api, int which); +int blocks_etc_modes(magic_api * api, int which); -int blocks_chalk_drip_init(magic_api * api) +int blocks_etc_init(magic_api * api) { char fname[1024]; @@ -102,20 +102,20 @@ int blocks_chalk_drip_init(magic_api * api) return (1); } -Uint32 blocks_chalk_drip_api_version(void) +Uint32 blocks_etc_api_version(void) { return (TP_MAGIC_API_VERSION); } // We have multiple tools: -int blocks_chalk_drip_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) +int blocks_etc_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) { return (NUM_TOOLS); } // Load our icons: -SDL_Surface *blocks_chalk_drip_get_icon(magic_api * api, int which) +SDL_Surface *blocks_etc_get_icon(magic_api * api, int which) { char fname[1024]; @@ -139,7 +139,7 @@ SDL_Surface *blocks_chalk_drip_get_icon(magic_api * api, int which) } // Return our names, localized: -char *blocks_chalk_drip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) +char *blocks_etc_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) { if (which == TOOL_BLOCKS) return (strdup(gettext_noop("Blocks"))); @@ -152,14 +152,14 @@ char *blocks_chalk_drip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) } // Return our group (all the same): -int blocks_chalk_drip_get_group(magic_api * api 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_chalk_drip_get_description(magic_api * api ATTRIBUTE_UNUSED, +char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode) { if (which == TOOL_BLOCKS) @@ -210,7 +210,7 @@ char *blocks_chalk_drip_get_description(magic_api * api ATTRIBUTE_UNUSED, // Do the effect: -static void blocks_chalk_drip_linecb(void *ptr, int which, +static void blocks_etc_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) { @@ -331,12 +331,12 @@ static void blocks_chalk_drip_linecb(void *ptr, int which, } // Affect the canvas on drag: -void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas, +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) { api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, - blocks_chalk_drip_linecb); + blocks_etc_linecb); if (ox > x) { @@ -362,13 +362,13 @@ void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void blocks_chalk_drip_click(magic_api * api, int which, int mode, +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) { if (mode == MODE_PAINT) { - blocks_chalk_drip_drag(api, which, canvas, last, x, y, x, y, update_rect); + blocks_etc_drag(api, which, canvas, last, x, y, x, y, update_rect); } else /* MODE_FULLSCREEN */ { @@ -382,7 +382,7 @@ void blocks_chalk_drip_click(magic_api * api, int which, int mode, } for (x = 0; x < canvas->w; x += EFFECT_REZ) { - blocks_chalk_drip_linecb(api, which, canvas, last, x, y); + blocks_etc_linecb(api, which, canvas, last, x, y); } } } @@ -398,7 +398,7 @@ void blocks_chalk_drip_click(magic_api * api, int which, int mode, } for (x = 0; x < canvas->w; x += EFFECT_REZ) { - blocks_chalk_drip_linecb(api, which, canvas, last, x, y); + blocks_etc_linecb(api, which, canvas, last, x, y); } } } @@ -412,7 +412,7 @@ void blocks_chalk_drip_click(magic_api * api, int which, int mode, } // Affect the canvas on release: -void blocks_chalk_drip_release(magic_api * api ATTRIBUTE_UNUSED, +void blocks_etc_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, @@ -422,7 +422,7 @@ void blocks_chalk_drip_release(magic_api * api ATTRIBUTE_UNUSED, } // No setup happened: -void blocks_chalk_drip_shutdown(magic_api * api ATTRIBUTE_UNUSED) +void blocks_etc_shutdown(magic_api * api ATTRIBUTE_UNUSED) { if (snd_effect[0] != NULL) Mix_FreeChunk(snd_effect[0]); @@ -432,33 +432,33 @@ void blocks_chalk_drip_shutdown(magic_api * api ATTRIBUTE_UNUSED) } // Record the color from Tux Paint: -void blocks_chalk_drip_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas 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_chalk_drip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, +int blocks_etc_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -void blocks_chalk_drip_switchin(magic_api * api ATTRIBUTE_UNUSED, +void blocks_etc_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { } -void blocks_chalk_drip_switchout(magic_api * api 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 blocks_chalk_drip_modes(magic_api * api ATTRIBUTE_UNUSED, int which) +int blocks_etc_modes(magic_api * api ATTRIBUTE_UNUSED, int which) { if (which == TOOL_BLOCKS || TOOL_CHALK) { diff --git a/magic/src/kaleidoscope_lens.c b/magic/src/kaleidox.c similarity index 67% rename from magic/src/kaleidoscope_lens.c rename to magic/src/kaleidox.c index 5f4921d4b..fab6b0f15 100644 --- a/magic/src/kaleidoscope_lens.c +++ b/magic/src/kaleidox.c @@ -1,10 +1,10 @@ -/* kaleidoscope_lens.c +/* kaleidox.c Transform the canvas as though looking at it through a kaleidoscope. Bill Kendrick - Last updated: March 8, 2023 + Last updated: March 19, 2023 */ #include @@ -23,25 +23,25 @@ enum { NUM_TOOLS }; -static char * kaleidoscope_lens_snd_filenames[NUM_TOOLS] = { +static char * kaleidox_snd_fnames[NUM_TOOLS] = { "kaleido-4.ogg", "kaleido-6.ogg", "kaleido-8.ogg", }; -static char * kaleidoscope_lens_icon_filenames[NUM_TOOLS] = { +static char * kaleidox_icon_fnames[NUM_TOOLS] = { "kaleido-4.png", "kaleido-6.png", "kaleido-8.png", }; -char * kaleidoscope_lens_names[NUM_TOOLS] = { +char * kaleidox_names[NUM_TOOLS] = { gettext_noop("Kaleido-4"), gettext_noop("Kaleido-6"), gettext_noop("Kaleido-8"), }; -char * kaleidoscope_lens_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!"), @@ -49,102 +49,102 @@ char * kaleidoscope_lens_descrs[NUM_TOOLS] = { Mix_Chunk *snd_effects[NUM_TOOLS]; -Uint32 kaleidoscope_lens_api_version(void); -int kaleidoscope_lens_init(magic_api * api); -int kaleidoscope_lens_get_tool_count(magic_api * api); -SDL_Surface *kaleidoscope_lens_get_icon(magic_api * api, int which); -char *kaleidoscope_lens_get_name(magic_api * api, int which); -int kaleidoscope_lens_get_group(magic_api * api, int which); -char *kaleidoscope_lens_get_description(magic_api * api, int which, int mode); -int kaleidoscope_lens_requires_colors(magic_api * api, int which); -int kaleidoscope_lens_modes(magic_api * api, int which); -void kaleidoscope_lens_shutdown(magic_api * api); -void kaleidoscope_lens_click(magic_api * api, int which, int mode, +Uint32 kaleidox_api_version(void); +int kaleidox_init(magic_api * api); +int kaleidox_get_tool_count(magic_api * api); +SDL_Surface *kaleidox_get_icon(magic_api * api, int which); +char *kaleidox_get_name(magic_api * api, int which); +int kaleidox_get_group(magic_api * api, int which); +char *kaleidox_get_description(magic_api * api, int which, int mode); +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); -void kaleidoscope_lens_set_color(magic_api * api, int which, SDL_Surface * canvas, +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); -void kaleidoscope_lens_drag(magic_api * api, int which, SDL_Surface * canvas, +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 kaleidoscope_lens_render(magic_api *, int which, SDL_Surface * canvas, +void kaleidox_render(magic_api *, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, int preview); -void kaleidoscope_lens_release(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); -void kaleidoscope_lens_switchin(magic_api * api, int which, int mode, +void kaleidox_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); -void kaleidoscope_lens_switchout(magic_api * api, int which, int mode, +void kaleidox_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); int mirror(int n, int max, int flip); -Uint32 kaleidoscope_lens_api_version(void) +Uint32 kaleidox_api_version(void) { return (TP_MAGIC_API_VERSION); } -int kaleidoscope_lens_init(magic_api * api) +int kaleidox_init(magic_api * api) { int i; char fname[1024]; for (i = 0; i < NUM_TOOLS; i++) { snprintf(fname, sizeof(fname), "%ssounds/magic/%s", - api->data_directory, kaleidoscope_lens_snd_filenames[i]); + api->data_directory, kaleidox_snd_fnames[i]); snd_effects[i] = Mix_LoadWAV(fname); } return (1); } -int kaleidoscope_lens_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) +int kaleidox_get_tool_count(magic_api * api ATTRIBUTE_UNUSED) { return (NUM_TOOLS); } -SDL_Surface *kaleidoscope_lens_get_icon(magic_api * api, int which) +SDL_Surface *kaleidox_get_icon(magic_api * api, int which) { char fname[1024]; snprintf(fname, sizeof(fname), "%simages/magic/%s", - api->data_directory, kaleidoscope_lens_icon_filenames[which]); + api->data_directory, kaleidox_icon_fnames[which]); return (IMG_Load(fname)); } -char *kaleidoscope_lens_get_name(magic_api * api ATTRIBUTE_UNUSED, +char *kaleidox_get_name(magic_api * api ATTRIBUTE_UNUSED, int which) { - return strdup(gettext(kaleidoscope_lens_names[which])); + return strdup(gettext(kaleidox_names[which])); } -int kaleidoscope_lens_get_group(magic_api * api ATTRIBUTE_UNUSED, +int kaleidox_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MAGIC_TYPE_PICTURE_WARPS; } -char *kaleidoscope_lens_get_description(magic_api * api ATTRIBUTE_UNUSED, +char *kaleidox_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED) { - return strdup(gettext(kaleidoscope_lens_descrs[which])); + return strdup(gettext(kaleidox_descrs[which])); } -int kaleidoscope_lens_requires_colors(magic_api * api ATTRIBUTE_UNUSED, +int kaleidox_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } -int kaleidoscope_lens_modes(magic_api * api ATTRIBUTE_UNUSED, +int kaleidox_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return MODE_PAINT_WITH_PREVIEW; } -void kaleidoscope_lens_shutdown(magic_api * api ATTRIBUTE_UNUSED) +void kaleidox_shutdown(magic_api * api ATTRIBUTE_UNUSED) { int i; @@ -155,13 +155,13 @@ void kaleidoscope_lens_shutdown(magic_api * api ATTRIBUTE_UNUSED) } void -kaleidoscope_lens_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, +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) { api->stopsound(); - kaleidoscope_lens_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); + kaleidox_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); } #define linear(start, end, dist, full) (start + (((end - start) * dist) / full)) @@ -189,7 +189,7 @@ int mirror(int n, int max, int flip) { } void -kaleidoscope_lens_drag(magic_api * api, int which, SDL_Surface * canvas, +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) { @@ -197,7 +197,7 @@ kaleidoscope_lens_drag(magic_api * api, int which, SDL_Surface * canvas, api->playsound(snd_effects[which], 128, 255); } - kaleidoscope_lens_render(api, which, canvas, snapshot, x, y, 1); + kaleidox_render(api, which, canvas, snapshot, x, y, 1); update_rect->x = 0; update_rect->y = 0; @@ -205,7 +205,7 @@ kaleidoscope_lens_drag(magic_api * api, int which, SDL_Surface * canvas, update_rect->h = canvas->h; } -void kaleidoscope_lens_render(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) { int off_x, off_y, sides, max_radius; @@ -285,13 +285,13 @@ void kaleidoscope_lens_render(magic_api * api, int which, SDL_Surface * canvas, } -void kaleidoscope_lens_release(magic_api * api, int which, +void kaleidox_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect) { - kaleidoscope_lens_render(api, which, canvas, snapshot, x, y, 0); + kaleidox_render(api, which, canvas, snapshot, x, y, 0); update_rect->x = 0; update_rect->y = 0; @@ -302,7 +302,7 @@ void kaleidoscope_lens_release(magic_api * api, int which, } -void kaleidoscope_lens_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, +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, @@ -311,13 +311,13 @@ void kaleidoscope_lens_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATT } -void kaleidoscope_lens_switchin(magic_api * api ATTRIBUTE_UNUSED, +void kaleidox_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) { } -void kaleidoscope_lens_switchout(magic_api * api ATTRIBUTE_UNUSED, +void kaleidox_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)