WIP Working on Magic tool grouping

Fretwork is in one group; Blocks, Chalk, and Drip in another.
The rest do not currently report (so will not load!).
No UI change to the Magic tool interface yet.
This commit is contained in:
Bill Kendrick 2021-09-20 23:09:33 -07:00
parent 4d1f7a7ee9
commit 3eece8635c
3 changed files with 31 additions and 4 deletions

View file

@ -4,7 +4,7 @@
Blocks, Chalk and Drip Magic Tools Plugin
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2021 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: July 8, 2008
Last updated: September 20, 2021
$Id$
*/
@ -56,6 +56,7 @@ 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, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas,
@ -135,6 +136,12 @@ char *blocks_chalk_drip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
return (NULL);
}
// Return our group (all the same):
int blocks_chalk_drip_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, int which, int mode ATTRIBUTE_UNUSED)
{

View file

@ -1,7 +1,7 @@
/*
* Draws fretwork
*
* Last updated: 2019-08-29
* Last updated: 2021-09-20
*/
#include "tp_magic_api.h"
@ -58,6 +58,7 @@ int fretwork_init(magic_api * api);
int fretwork_get_tool_count(magic_api * api);
SDL_Surface *fretwork_get_icon(magic_api * api, int which);
char *fretwork_get_name(magic_api * api, int which);
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,
@ -171,6 +172,11 @@ SDL_Surface *fretwork_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
return (IMG_Load(fname));
}
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)
{
return strdup(gettext_noop("Fretwork"));
@ -179,7 +185,7 @@ char *fretwork_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
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."));
}

View file

@ -1390,6 +1390,7 @@ static void special_notify(int flags);
typedef struct magic_funcs_s
{
int (*get_tool_count) (magic_api *);
int (*get_group) (magic_api *, int);
char *(*get_name) (magic_api *, int);
SDL_Surface *(*get_icon) (magic_api *, int);
char *(*get_description) (magic_api *, int, int);
@ -1415,6 +1416,7 @@ typedef struct magic_s
int mode; /* Current mode (paint or fullscreen) */
int avail_modes; /* Available modes (paint &/or fullscreen) */
int colors; /* Whether magic tool accepts colors */
int group; /* Which group of magic tools this lives in */
char *name; /* Name of magic tool */
char *tip[MAX_MODES]; /* Description of magic tool, in each possible mode */
SDL_Surface *img_icon;
@ -19106,6 +19108,10 @@ static void load_magic_plugins(void)
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_name");
magic_funcs[num_plugin_files].get_name =
SDL_LoadFunction(magic_handle[num_plugin_files], funcname);
@ -19166,6 +19172,7 @@ static void load_magic_plugins(void)
//EP added (intptr_t) to avoid warning on x64 on all lines below
printf("get_tool_count = 0x%x\n",
(int)(intptr_t) magic_funcs[num_plugin_files].get_tool_count);
printf("get_group = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_group);
printf("get_name = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_name);
printf("get_icon = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_icon);
printf("get_description = 0x%x\n",
@ -19191,6 +19198,11 @@ static void load_magic_plugins(void)
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);
err = 1;
}
if (magic_funcs[num_plugin_files].get_name == NULL)
{
fprintf(stderr, "Error: plugin %s is missing get_name\n", fname);
@ -19303,6 +19315,8 @@ static void load_magic_plugins(void)
magics[num_magics].idx = i;
magics[num_magics].place = plc;
magics[num_magics].handle_idx = num_plugin_files;
magics[num_magics].group =
magic_funcs[num_plugin_files].get_group(magic_api_struct, i);
magics[num_magics].name =
magic_funcs[num_plugin_files].get_name(magic_api_struct, i);