Storing Magic tools within groups
Still a WIP; no way to paginate yet. (So now, only able to access group #0 (MAGIC_TYPE_DISTORTS) magic tools)
This commit is contained in:
parent
8b30a278c2
commit
901230c710
1 changed files with 215 additions and 142 deletions
357
src/tuxpaint.c
357
src/tuxpaint.c
|
|
@ -1424,14 +1424,16 @@ typedef struct magic_s
|
||||||
} magic_t;
|
} magic_t;
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: Drop the 512 constants :^P */
|
#define MAX_MAGIC_GROUPS 16
|
||||||
|
#define MAX_MAGICS_PER_GROUP 128
|
||||||
|
|
||||||
static int num_plugin_files; /* How many shared object files we went through */
|
static int num_plugin_files; /* How many shared object files we went through */
|
||||||
static void *magic_handle[512]; /* Handle to shared object (to be unloaded later) *//* FIXME: Unload them! */
|
static void *magic_handle[MAX_MAGIC_GROUPS * MAX_MAGICS_PER_GROUP]; /* Handle to shared object (to be unloaded later) *//* FIXME: Unload them! */
|
||||||
static magic_funcs_t magic_funcs[512]; /* Pointer to shared objects' functions */
|
static magic_funcs_t magic_funcs[MAX_MAGIC_GROUPS * MAX_MAGICS_PER_GROUP]; /* Pointer to shared objects' functions */
|
||||||
|
|
||||||
static magic_t magics[512];
|
static magic_t magics[MAX_MAGIC_GROUPS][MAX_MAGICS_PER_GROUP];
|
||||||
static int num_magics; /* How many magic tools were loaded (note: shared objs may report more than 1 tool) */
|
static int num_magics[MAX_MAGIC_GROUPS]; /* How many magic tools were loaded (note: shared objs may report more than 1 tool) */
|
||||||
|
static int num_magics_total;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
@ -1871,8 +1873,9 @@ static int brush_counter, brush_frame;
|
||||||
|
|
||||||
static unsigned cur_color;
|
static unsigned cur_color;
|
||||||
static int cur_tool, cur_brush, old_tool;
|
static int cur_tool, cur_brush, old_tool;
|
||||||
|
static int magic_group = 0;
|
||||||
static int cur_stamp[MAX_STAMP_GROUPS];
|
static int cur_stamp[MAX_STAMP_GROUPS];
|
||||||
static int cur_shape, cur_magic;
|
static int cur_shape, cur_magic[MAX_MAGIC_GROUPS];
|
||||||
static int cur_font, cur_eraser, cur_fill, fill_drag_started;
|
static int cur_font, cur_eraser, cur_fill, fill_drag_started;
|
||||||
static int cursor_left, cursor_x, cursor_y, cursor_textwidth; /* canvas-relative */
|
static int cursor_left, cursor_x, cursor_y, cursor_textwidth; /* canvas-relative */
|
||||||
static int old_cursor_x, old_cursor_y;
|
static int old_cursor_x, old_cursor_y;
|
||||||
|
|
@ -1883,7 +1886,8 @@ static char starter_id[FILENAME_MAX];
|
||||||
static char template_id[FILENAME_MAX];
|
static char template_id[FILENAME_MAX];
|
||||||
static int brush_scroll;
|
static int brush_scroll;
|
||||||
static int stamp_scroll[MAX_STAMP_GROUPS];
|
static int stamp_scroll[MAX_STAMP_GROUPS];
|
||||||
static int font_scroll, magic_scroll, tool_scroll;
|
static int magic_scroll[MAX_MAGIC_GROUPS];
|
||||||
|
static int font_scroll, tool_scroll;
|
||||||
static int eraser_scroll, shape_scroll, fill_scroll;
|
static int eraser_scroll, shape_scroll, fill_scroll;
|
||||||
|
|
||||||
static int eraser_sound;
|
static int eraser_sound;
|
||||||
|
|
@ -3302,18 +3306,18 @@ static void mainloop(void)
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
keybd_flag = 0;
|
keybd_flag = 0;
|
||||||
cur_thing = cur_magic;
|
cur_thing = cur_magic[magic_group];
|
||||||
num_things = num_magics;
|
num_things = num_magics[magic_group];
|
||||||
thing_scroll = &magic_scroll;
|
thing_scroll = &(magic_scroll[magic_group]);
|
||||||
magic_current_snd_ptr = NULL;
|
magic_current_snd_ptr = NULL;
|
||||||
draw_magic();
|
draw_magic();
|
||||||
draw_colors(magics[cur_magic].colors);
|
draw_colors(magics[magic_group][cur_thing].colors);
|
||||||
|
|
||||||
if (magics[cur_magic].colors)
|
if (magics[magic_group][cur_thing].colors)
|
||||||
magic_funcs[magics[cur_magic].handle_idx].set_color(magic_api_struct,
|
magic_funcs[magics[magic_group][cur_thing].handle_idx].set_color(magic_api_struct,
|
||||||
color_hexes[cur_color][0],
|
color_hexes[cur_color][0],
|
||||||
color_hexes[cur_color][1],
|
color_hexes[cur_color][1],
|
||||||
color_hexes[cur_color][2]);
|
color_hexes[cur_color][2]);
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_ERASER)
|
else if (cur_tool == TOOL_ERASER)
|
||||||
{
|
{
|
||||||
|
|
@ -3808,39 +3812,45 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
|
int grp;
|
||||||
|
int cur;
|
||||||
|
|
||||||
|
grp = magic_group;
|
||||||
|
cur = cur_magic[grp];
|
||||||
|
|
||||||
/* Magic pagination */
|
/* Magic pagination */
|
||||||
if (which == 0 || which == 1)
|
if (which == 0 || which == 1)
|
||||||
printf("FIXME: Paginate!\n");
|
printf("FIXME: Paginate!\n");
|
||||||
|
|
||||||
/* Magic controls! */
|
/* Magic controls! */
|
||||||
if (which == 3 && magics[cur_magic].avail_modes & MODE_FULLSCREEN)
|
if (which == 3 && magics[grp][cur].avail_modes & MODE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
magic_switchout(canvas);
|
magic_switchout(canvas);
|
||||||
magics[cur_magic].mode = MODE_FULLSCREEN;
|
magics[grp][cur].mode = MODE_FULLSCREEN;
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
draw_magic();
|
draw_magic();
|
||||||
update_screen_rect(&r_toolopt);
|
update_screen_rect(&r_toolopt);
|
||||||
}
|
}
|
||||||
else if (which == 2 && magics[cur_magic].avail_modes & MODE_PAINT)
|
else if (which == 2 && magics[grp][cur].avail_modes & MODE_PAINT)
|
||||||
{
|
{
|
||||||
magic_switchout(canvas);
|
magic_switchout(canvas);
|
||||||
magics[cur_magic].mode = MODE_PAINT;
|
magics[grp][cur].mode = MODE_PAINT;
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
draw_magic();
|
draw_magic();
|
||||||
update_screen_rect(&r_toolopt);
|
update_screen_rect(&r_toolopt);
|
||||||
}
|
}
|
||||||
else if (which == 2 && magics[cur_magic].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
else if (which == 2 && magics[grp][cur].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
||||||
{
|
{
|
||||||
magic_switchout(canvas);
|
magic_switchout(canvas);
|
||||||
magics[cur_magic].mode = MODE_PAINT_WITH_PREVIEW;
|
magics[grp][cur].mode = MODE_PAINT_WITH_PREVIEW;
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
draw_magic();
|
draw_magic();
|
||||||
update_screen_rect(&r_toolopt);
|
update_screen_rect(&r_toolopt);
|
||||||
}
|
}
|
||||||
else if (which == 2 && magics[cur_magic].avail_modes & MODE_ONECLICK)
|
else if (which == 2 && magics[grp][cur].avail_modes & MODE_ONECLICK)
|
||||||
{
|
{
|
||||||
magic_switchout(canvas);
|
magic_switchout(canvas);
|
||||||
magics[cur_magic].mode = MODE_ONECLICK;
|
magics[grp][cur].mode = MODE_ONECLICK;
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
draw_magic();
|
draw_magic();
|
||||||
update_screen_rect(&r_toolopt);
|
update_screen_rect(&r_toolopt);
|
||||||
|
|
@ -4302,23 +4312,29 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
if (cur_thing != cur_magic)
|
int grp;
|
||||||
|
int cur;
|
||||||
|
|
||||||
|
grp = magic_group;
|
||||||
|
cur = cur_magic[grp];
|
||||||
|
|
||||||
|
if (cur_thing != cur)
|
||||||
{
|
{
|
||||||
magic_switchout(canvas);
|
magic_switchout(canvas);
|
||||||
|
|
||||||
cur_magic = cur_thing;
|
cur_magic[grp] = cur_thing;
|
||||||
draw_colors(magics[cur_magic].colors);
|
draw_colors(magics[grp][cur].colors);
|
||||||
|
|
||||||
if (magics[cur_magic].colors)
|
if (magics[grp][cur].colors)
|
||||||
magic_funcs[magics[cur_magic].handle_idx].set_color(magic_api_struct,
|
magic_funcs[magics[grp][cur].handle_idx].set_color(magic_api_struct,
|
||||||
color_hexes[cur_color][0],
|
color_hexes[cur_color][0],
|
||||||
color_hexes[cur_color][1],
|
color_hexes[cur_color][1],
|
||||||
color_hexes[cur_color][2]);
|
color_hexes[cur_color][2]);
|
||||||
|
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_tux_text(TUX_GREAT, magics[cur_magic].tip[magic_modeint(magics[cur_magic].mode)], 1);
|
draw_tux_text(TUX_GREAT, magics[grp][cur].tip[magic_modeint(magics[grp][cur].mode)], 1);
|
||||||
|
|
||||||
if (do_draw)
|
if (do_draw)
|
||||||
draw_magic();
|
draw_magic();
|
||||||
|
|
@ -4404,10 +4420,11 @@ static void mainloop(void)
|
||||||
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
|
||||||
do_render_cur_text(0);
|
do_render_cur_text(0);
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
magic_funcs[magics[cur_magic].handle_idx].set_color(magic_api_struct,
|
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].set_color(
|
||||||
color_hexes[cur_color][0],
|
magic_api_struct,
|
||||||
color_hexes[cur_color][1],
|
color_hexes[cur_color][0],
|
||||||
color_hexes[cur_color][2]);
|
color_hexes[cur_color][1],
|
||||||
|
color_hexes[cur_color][2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4517,6 +4534,12 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_MAGIC)
|
else if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
|
int grp;
|
||||||
|
int cur;
|
||||||
|
|
||||||
|
grp = magic_group;
|
||||||
|
cur = cur_magic[grp];
|
||||||
|
|
||||||
if (!emulate_button_pressed)
|
if (!emulate_button_pressed)
|
||||||
{
|
{
|
||||||
int undo_ctr;
|
int undo_ctr;
|
||||||
|
|
@ -4551,12 +4574,12 @@ static void mainloop(void)
|
||||||
|
|
||||||
reset_touched();
|
reset_touched();
|
||||||
|
|
||||||
magic_funcs[magics[cur_magic].handle_idx].click(magic_api_struct,
|
magic_funcs[magics[grp][cur].handle_idx].click(magic_api_struct,
|
||||||
magics[cur_magic].idx,
|
magics[grp][cur].idx,
|
||||||
magics[cur_magic].mode,
|
magics[grp][cur].mode,
|
||||||
canvas, last, old_x, old_y, &update_rect);
|
canvas, last, old_x, old_y, &update_rect);
|
||||||
|
|
||||||
draw_tux_text(TUX_GREAT, magics[cur_magic].tip[magic_modeint(magics[cur_magic].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_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);
|
||||||
|
|
@ -4564,7 +4587,7 @@ static void mainloop(void)
|
||||||
|
|
||||||
if (mouseaccessibility)
|
if (mouseaccessibility)
|
||||||
{
|
{
|
||||||
if (magics[cur_magic].mode != MODE_FULLSCREEN && magics[cur_magic].mode != MODE_ONECLICK) /* Note: some non-fullscreen tools are also click-only (not click-and-drag) -bjk 2011.04.26 */
|
if (magics[grp][cur].mode != MODE_FULLSCREEN && magics[grp][cur].mode != MODE_ONECLICK) /* Note: some non-fullscreen tools are also click-only (not click-and-drag) -bjk 2011.04.26 */
|
||||||
emulate_button_pressed = !emulate_button_pressed;
|
emulate_button_pressed = !emulate_button_pressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5249,9 +5272,16 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_MAGIC
|
else if (cur_tool == TOOL_MAGIC
|
||||||
&& (magics[cur_magic].mode == MODE_PAINT || magics[cur_magic].mode == MODE_ONECLICK
|
&& (magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT
|
||||||
|| magics[cur_magic].mode == MODE_PAINT_WITH_PREVIEW))
|
|| magics[magic_group][cur_magic[magic_group]].mode == MODE_ONECLICK
|
||||||
|
|| magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT_WITH_PREVIEW))
|
||||||
{
|
{
|
||||||
|
int grp;
|
||||||
|
int cur;
|
||||||
|
|
||||||
|
grp = magic_group;
|
||||||
|
cur = cur_magic[grp];
|
||||||
|
|
||||||
if (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed))
|
if (!mouseaccessibility || (mouseaccessibility && !emulate_button_pressed))
|
||||||
{
|
{
|
||||||
int undo_ctr;
|
int undo_ctr;
|
||||||
|
|
@ -5271,11 +5301,11 @@ static void mainloop(void)
|
||||||
update_rect.w = 0;
|
update_rect.w = 0;
|
||||||
update_rect.h = 0;
|
update_rect.h = 0;
|
||||||
|
|
||||||
magic_funcs[magics[cur_magic].handle_idx].release(magic_api_struct,
|
magic_funcs[magics[grp][cur].handle_idx].release(magic_api_struct,
|
||||||
magics[cur_magic].idx,
|
magics[grp][cur].idx,
|
||||||
canvas, last, old_x, old_y, &update_rect);
|
canvas, last, old_x, old_y, &update_rect);
|
||||||
|
|
||||||
draw_tux_text(TUX_GREAT, magics[cur_magic].tip[magic_modeint(magics[cur_magic].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_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);
|
||||||
|
|
@ -5565,8 +5595,9 @@ static void mainloop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_MAGIC
|
else if (cur_tool == TOOL_MAGIC
|
||||||
&& (magics[cur_magic].mode == MODE_PAINT || magics[cur_magic].mode == MODE_ONECLICK
|
&& (magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT
|
||||||
|| magics[cur_magic].mode == MODE_PAINT_WITH_PREVIEW))
|
|| magics[magic_group][cur_magic[magic_group]].mode == MODE_ONECLICK
|
||||||
|
|| magics[magic_group][cur_magic[magic_group]].mode == MODE_PAINT_WITH_PREVIEW))
|
||||||
{
|
{
|
||||||
int undo_ctr;
|
int undo_ctr;
|
||||||
SDL_Surface *last;
|
SDL_Surface *last;
|
||||||
|
|
@ -5585,10 +5616,11 @@ static void mainloop(void)
|
||||||
update_rect.w = 0;
|
update_rect.w = 0;
|
||||||
update_rect.h = 0;
|
update_rect.h = 0;
|
||||||
|
|
||||||
magic_funcs[magics[cur_magic].handle_idx].drag(magic_api_struct,
|
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].drag(
|
||||||
magics[cur_magic].idx,
|
magic_api_struct,
|
||||||
canvas, last,
|
magics[magic_group][cur_magic[magic_group]].idx,
|
||||||
old_x, old_y, new_x, new_y, &update_rect);
|
canvas, last,
|
||||||
|
old_x, old_y, new_x, new_y, &update_rect);
|
||||||
|
|
||||||
update_canvas(update_rect.x, update_rect.y,
|
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);
|
||||||
|
|
@ -8261,15 +8293,20 @@ static SDL_Surface *do_render_button_label(const char *const label)
|
||||||
*/
|
*/
|
||||||
static void create_button_labels(void)
|
static void create_button_labels(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
/* Main tools */
|
/* Main tools */
|
||||||
for (i = 0; i < NUM_TOOLS; i++)
|
for (i = 0; i < NUM_TOOLS; i++)
|
||||||
img_tool_names[i] = do_render_button_label(tool_names[i]);
|
img_tool_names[i] = do_render_button_label(tool_names[i]);
|
||||||
|
|
||||||
/* Magic Tools */
|
/* Magic Tools */
|
||||||
for (i = 0; i < num_magics; i++)
|
for (i = 0; i < MAX_MAGIC_GROUPS; i++)
|
||||||
magics[i].img_name = do_render_button_label(magics[i].name);
|
{
|
||||||
|
for (j = 0; j < num_magics[i]; j++)
|
||||||
|
{
|
||||||
|
magics[i][j].img_name = do_render_button_label(magics[i][j].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Shapes for Shape Tool */
|
/* Shapes for Shape Tool */
|
||||||
for (i = 0; i < NUM_SHAPES; i++)
|
for (i = 0; i < NUM_SHAPES; i++)
|
||||||
|
|
@ -8634,7 +8671,7 @@ static void draw_magic(void)
|
||||||
if (disable_magic_controls)
|
if (disable_magic_controls)
|
||||||
most = most + gd_toolopt.cols;
|
most = most + gd_toolopt.cols;
|
||||||
|
|
||||||
if (num_magics > most + TOOLOFFSET)
|
if (num_magics[magic_group] > most + TOOLOFFSET)
|
||||||
{
|
{
|
||||||
off_y = img_scroll_down->h;
|
off_y = img_scroll_down->h;
|
||||||
max = (most - 2) + TOOLOFFSET;
|
max = (most - 2) + TOOLOFFSET;
|
||||||
|
|
@ -8642,7 +8679,7 @@ static void draw_magic(void)
|
||||||
dest.x = WINDOW_WIDTH - r_ttoolopt.w;
|
dest.x = WINDOW_WIDTH - r_ttoolopt.w;
|
||||||
dest.y = r_ttoolopt.h;
|
dest.y = r_ttoolopt.h;
|
||||||
|
|
||||||
if (magic_scroll > 0)
|
if (magic_scroll[magic_group] > 0)
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(img_scroll_up, NULL, screen, &dest);
|
SDL_BlitSurface(img_scroll_up, NULL, screen, &dest);
|
||||||
}
|
}
|
||||||
|
|
@ -8654,7 +8691,7 @@ static void draw_magic(void)
|
||||||
dest.x = WINDOW_WIDTH - r_ttoolopt.w;
|
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 < num_magics - (most - 2) - TOOLOFFSET)
|
if (magic_scroll[magic_group] < num_magics[magic_group] - (most - 2) - TOOLOFFSET)
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(img_scroll_down, NULL, screen, &dest);
|
SDL_BlitSurface(img_scroll_down, NULL, screen, &dest);
|
||||||
}
|
}
|
||||||
|
|
@ -8670,16 +8707,16 @@ static void draw_magic(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (magic = magic_scroll; magic < magic_scroll + max; magic++)
|
for (magic = magic_scroll[magic_group]; magic < magic_scroll[magic_group] + max; magic++)
|
||||||
{
|
{
|
||||||
i = magic - magic_scroll;
|
i = magic - magic_scroll[magic_group];
|
||||||
|
|
||||||
dest.x = ((i % 2) * button_w) + (WINDOW_WIDTH - r_ttoolopt.w);
|
dest.x = ((i % 2) * button_w) + (WINDOW_WIDTH - r_ttoolopt.w);
|
||||||
dest.y = ((i / 2) * button_h) + r_ttoolopt.h + off_y;
|
dest.y = ((i / 2) * button_h) + r_ttoolopt.h + off_y;
|
||||||
|
|
||||||
if (magic < num_magics)
|
if (magic < num_magics[magic_group])
|
||||||
{
|
{
|
||||||
if (magic == cur_magic)
|
if (magic == cur_magic[magic_group])
|
||||||
{
|
{
|
||||||
SDL_BlitSurface(img_btn_down, NULL, screen, &dest);
|
SDL_BlitSurface(img_btn_down, NULL, screen, &dest);
|
||||||
}
|
}
|
||||||
|
|
@ -8691,13 +8728,13 @@ static void draw_magic(void)
|
||||||
dest.x = WINDOW_WIDTH - r_ttoolopt.w + ((i % 2) * button_w) + 4;
|
dest.x = WINDOW_WIDTH - r_ttoolopt.w + ((i % 2) * button_w) + 4;
|
||||||
dest.y = ((i / 2) * button_h) + r_ttoolopt.h + 4 + off_y;
|
dest.y = ((i / 2) * button_h) + r_ttoolopt.h + 4 + off_y;
|
||||||
|
|
||||||
SDL_BlitSurface(magics[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].img_name->w) / 2;
|
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].img_name->h) + off_y);
|
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);
|
||||||
|
|
||||||
SDL_BlitSurface(magics[magic].img_name, NULL, screen, &dest);
|
SDL_BlitSurface(magics[magic_group][magic].img_name, NULL, screen, &dest);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -8746,14 +8783,19 @@ static void draw_magic(void)
|
||||||
if (!disable_magic_controls)
|
if (!disable_magic_controls)
|
||||||
{
|
{
|
||||||
SDL_Surface *button_color;
|
SDL_Surface *button_color;
|
||||||
|
int grp, cur;
|
||||||
|
|
||||||
|
grp = magic_group;
|
||||||
|
cur = cur_magic[magic_group];
|
||||||
|
|
||||||
|
|
||||||
/* Show paint button: */
|
/* Show paint button: */
|
||||||
|
|
||||||
if (magics[cur_magic].mode == MODE_PAINT || magics[cur_magic].mode == MODE_ONECLICK
|
if (magics[grp][cur].mode == MODE_PAINT || magics[grp][cur].mode == MODE_ONECLICK
|
||||||
|| magics[cur_magic].mode == MODE_PAINT_WITH_PREVIEW)
|
|| magics[grp][cur].mode == MODE_PAINT_WITH_PREVIEW)
|
||||||
button_color = img_btn_down; /* Active */
|
button_color = img_btn_down; /* Active */
|
||||||
else if (magics[cur_magic].avail_modes & MODE_PAINT || magics[cur_magic].avail_modes & MODE_ONECLICK
|
else if (magics[grp][cur].avail_modes & MODE_PAINT || magics[grp][cur].avail_modes & MODE_ONECLICK
|
||||||
|| magics[cur_magic].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
|| magics[grp][cur].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
||||||
button_color = img_btn_up; /* Available, but not active */
|
button_color = img_btn_up; /* Available, but not active */
|
||||||
else
|
else
|
||||||
button_color = img_btn_off; /* Unavailable */
|
button_color = img_btn_off; /* Unavailable */
|
||||||
|
|
@ -8771,9 +8813,9 @@ static void draw_magic(void)
|
||||||
|
|
||||||
/* Show fullscreen button: */
|
/* Show fullscreen button: */
|
||||||
|
|
||||||
if (magics[cur_magic].mode == MODE_FULLSCREEN)
|
if (magics[grp][cur].mode == MODE_FULLSCREEN)
|
||||||
button_color = img_btn_down; /* Active */
|
button_color = img_btn_down; /* Active */
|
||||||
else if (magics[cur_magic].avail_modes & MODE_FULLSCREEN)
|
else if (magics[grp][cur].avail_modes & MODE_FULLSCREEN)
|
||||||
button_color = img_btn_up; /* Available, but not active */
|
button_color = img_btn_up; /* Available, but not active */
|
||||||
else
|
else
|
||||||
button_color = img_btn_off; /* Unavailable */
|
button_color = img_btn_off; /* Unavailable */
|
||||||
|
|
@ -10939,7 +10981,7 @@ static void reset_avail_tools(void)
|
||||||
if (num_stamps[0] == 0)
|
if (num_stamps[0] == 0)
|
||||||
tool_avail[TOOL_STAMP] = 0;
|
tool_avail[TOOL_STAMP] = 0;
|
||||||
|
|
||||||
if (num_magics == 0)
|
if (num_magics_total == 0)
|
||||||
tool_avail[TOOL_MAGIC] = 0;
|
tool_avail[TOOL_MAGIC] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13217,10 +13259,13 @@ static void cleanup(void)
|
||||||
free_surface_array(img_tools, NUM_TOOLS);
|
free_surface_array(img_tools, NUM_TOOLS);
|
||||||
free_surface_array(img_tool_names, NUM_TOOLS);
|
free_surface_array(img_tool_names, NUM_TOOLS);
|
||||||
free_surface_array(img_title_names, NUM_TITLES);
|
free_surface_array(img_title_names, NUM_TITLES);
|
||||||
for (i = 0; i < num_magics; i++)
|
for (i = 0; i < MAX_MAGIC_GROUPS; i++)
|
||||||
{
|
{
|
||||||
free_surface(&(magics[i].img_icon));
|
for (j = 0; j < num_magics[i]; j++)
|
||||||
free_surface(&(magics[i].img_name));
|
{
|
||||||
|
free_surface(&(magics[i][j].img_icon));
|
||||||
|
free_surface(&(magics[i][j].img_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free_surface_array(img_shapes, NUM_SHAPES);
|
free_surface_array(img_shapes, NUM_SHAPES);
|
||||||
free_surface_array(img_shape_names, NUM_SHAPES);
|
free_surface_array(img_shape_names, NUM_SHAPES);
|
||||||
|
|
@ -19069,7 +19114,9 @@ static void load_magic_plugins(void)
|
||||||
char funcname[512];
|
char funcname[512];
|
||||||
|
|
||||||
num_plugin_files = 0;
|
num_plugin_files = 0;
|
||||||
num_magics = 0;
|
for (i = 0; i < MAX_MAGIC_GROUPS; i++)
|
||||||
|
num_magics[i] = 0;
|
||||||
|
num_magics_total = 0;
|
||||||
|
|
||||||
for (plc = 0; plc < NUM_MAGIC_PLACES; plc++)
|
for (plc = 0; plc < NUM_MAGIC_PLACES; plc++)
|
||||||
{
|
{
|
||||||
|
|
@ -19363,68 +19410,80 @@ static void load_magic_plugins(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int j;
|
int j, group, idx;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
magics[num_magics].idx = i;
|
group = magic_funcs[num_plugin_files].get_group(magic_api_struct, i);
|
||||||
magics[num_magics].place = plc;
|
if (group < MAX_MAGIC_GROUPS)
|
||||||
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);
|
|
||||||
|
|
||||||
magics[num_magics].avail_modes =
|
|
||||||
magic_funcs[num_plugin_files].modes(magic_api_struct, i);
|
|
||||||
|
|
||||||
for (j = 0; j < MAX_MODES; j++)
|
|
||||||
{
|
{
|
||||||
magics[num_magics].tip[j] = NULL;
|
idx = num_magics[group];
|
||||||
if (j)
|
|
||||||
|
magics[group][idx].idx = i;
|
||||||
|
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].avail_modes =
|
||||||
|
magic_funcs[num_plugin_files].modes(magic_api_struct, i);
|
||||||
|
|
||||||
|
for (j = 0; j < MAX_MODES; j++)
|
||||||
{
|
{
|
||||||
if (magics[num_magics].avail_modes & MODE_FULLSCREEN)
|
magics[group][idx].tip[j] = NULL;
|
||||||
magics[num_magics].tip[j] =
|
if (j)
|
||||||
magic_funcs[num_plugin_files].get_description(magic_api_struct, i,
|
{
|
||||||
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);
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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);
|
||||||
|
if (magics[group][idx].avail_modes & MODE_PAINT)
|
||||||
|
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)
|
||||||
|
magics[group][idx].mode = MODE_PAINT_WITH_PREVIEW;
|
||||||
else
|
else
|
||||||
{
|
magics[group][idx].mode = MODE_FULLSCREEN;
|
||||||
if (magics[num_magics].avail_modes & MODE_PAINT)
|
|
||||||
magics[num_magics].tip[j] =
|
magics[group][idx].img_icon =
|
||||||
magic_funcs[num_plugin_files].get_description(magic_api_struct, i,
|
thumbnail(magic_funcs[num_plugin_files].get_icon(magic_api_struct, i), 40 * button_w / ORIGINAL_BUTTON_SIZE, 30 * button_h / ORIGINAL_BUTTON_SIZE, 1);
|
||||||
MODE_PAINT);
|
|
||||||
else if (magics[num_magics].avail_modes & MODE_ONECLICK)
|
#ifdef DEBUG
|
||||||
magics[num_magics].tip[j] =
|
printf("-- %s\n", magics[group][idx].name);
|
||||||
magic_funcs[num_plugin_files].get_description(magic_api_struct, i,
|
printf("avail_modes = %d\n", magics[group][idx].avail_modes);
|
||||||
MODE_ONECLICK);
|
#endif
|
||||||
else if (magics[num_magics].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
|
||||||
magics[num_magics].tip[j] =
|
num_magics[group]++;
|
||||||
magic_funcs[num_plugin_files].get_description(magic_api_struct, i,
|
num_magics_total++;
|
||||||
MODE_PAINT_WITH_PREVIEW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
magics[num_magics].colors =
|
|
||||||
magic_funcs[num_plugin_files].requires_colors(magic_api_struct, i);
|
|
||||||
if (magics[num_magics].avail_modes & MODE_PAINT)
|
|
||||||
magics[num_magics].mode = MODE_PAINT;
|
|
||||||
else if (magics[num_magics].avail_modes & MODE_ONECLICK)
|
|
||||||
magics[num_magics].mode = MODE_ONECLICK;
|
|
||||||
else if (magics[num_magics].avail_modes & MODE_PAINT_WITH_PREVIEW)
|
|
||||||
magics[num_magics].mode = MODE_PAINT_WITH_PREVIEW;
|
|
||||||
else
|
else
|
||||||
magics[num_magics].mode = MODE_FULLSCREEN;
|
{
|
||||||
|
fprintf(stderr, "Error: plugin %s mode # %d reported group %d (higher than %d)\n",
|
||||||
magics[num_magics].img_icon =
|
fname, i, group, MAX_MAGIC_GROUPS - 1);
|
||||||
thumbnail( magic_funcs[num_plugin_files].get_icon(magic_api_struct, i), 40 * button_w / ORIGINAL_BUTTON_SIZE, 30 * button_h / ORIGINAL_BUTTON_SIZE, 1);
|
fflush(stderr);
|
||||||
|
}
|
||||||
#ifdef DEBUG
|
|
||||||
printf("-- %s\n", magics[num_magics].name);
|
|
||||||
printf("avail_modes = %d\n", magics[num_magics].avail_modes);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
num_magics++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
num_plugin_files++;
|
num_plugin_files++;
|
||||||
|
|
@ -19446,10 +19505,12 @@ static void load_magic_plugins(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qsort(magics, num_magics, sizeof(magic_t), magic_sort);
|
for (i = 0; i < MAX_MAGIC_GROUPS; i++) {
|
||||||
|
qsort(magics[i], num_magics[i], sizeof(magic_t), magic_sort);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Loaded %d magic tools from %d plug-in files\n", num_magics, num_plugin_files);
|
printf("Loaded %d magic tools from %d plug-in files\n", num_magics_total, num_plugin_files);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -21803,11 +21864,16 @@ static void magic_switchout(SDL_Surface * last)
|
||||||
|
|
||||||
if (cur_tool == TOOL_MAGIC)
|
if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
magic_funcs[magics[cur_magic].handle_idx].switchout(magic_api_struct,
|
int grp, cur;
|
||||||
magics[cur_magic].idx, magics[cur_magic].mode, canvas, last);
|
|
||||||
|
grp = magic_group;
|
||||||
|
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);
|
||||||
update_canvas(0, 0, canvas->w, canvas->h);
|
update_canvas(0, 0, canvas->w, canvas->h);
|
||||||
|
|
||||||
if (was_clicking && magics[cur_magic].mode == MODE_PAINT_WITH_PREVIEW)
|
if (was_clicking && magics[grp][cur].mode == MODE_PAINT_WITH_PREVIEW)
|
||||||
{
|
{
|
||||||
/* Clean up preview! */
|
/* Clean up preview! */
|
||||||
do_undo();
|
do_undo();
|
||||||
|
|
@ -21825,8 +21891,13 @@ static void magic_switchin(SDL_Surface * last)
|
||||||
{
|
{
|
||||||
if (cur_tool == TOOL_MAGIC)
|
if (cur_tool == TOOL_MAGIC)
|
||||||
{
|
{
|
||||||
magic_funcs[magics[cur_magic].handle_idx].switchin(magic_api_struct,
|
int grp, cur;
|
||||||
magics[cur_magic].idx, magics[cur_magic].mode, canvas, last);
|
|
||||||
|
grp = magic_group;
|
||||||
|
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);
|
||||||
|
|
||||||
/* In case the Magic tool's switchin() called update_progress_bar(),
|
/* In case the Magic tool's switchin() called update_progress_bar(),
|
||||||
let's put the old Tux text back: */
|
let's put the old Tux text back: */
|
||||||
|
|
@ -25527,7 +25598,6 @@ static void claim_to_be_ready(void)
|
||||||
for (i = 0; i < MAX_STAMP_GROUPS; i++)
|
for (i = 0; i < MAX_STAMP_GROUPS; i++)
|
||||||
cur_stamp[i] = 0;
|
cur_stamp[i] = 0;
|
||||||
cur_shape = SHAPE_SQUARE;
|
cur_shape = SHAPE_SQUARE;
|
||||||
cur_magic = 0;
|
|
||||||
cur_font = 0;
|
cur_font = 0;
|
||||||
cur_eraser = 0;
|
cur_eraser = 0;
|
||||||
cur_fill = 0;
|
cur_fill = 0;
|
||||||
|
|
@ -25551,10 +25621,13 @@ static void claim_to_be_ready(void)
|
||||||
|
|
||||||
brush_scroll = 0;
|
brush_scroll = 0;
|
||||||
for (i = 0; i < MAX_STAMP_GROUPS; i++)
|
for (i = 0; i < MAX_STAMP_GROUPS; i++)
|
||||||
stamp_scroll[i] = 0;
|
{
|
||||||
|
stamp_scroll[i] = 0;
|
||||||
|
magic_scroll[i] = 0;
|
||||||
|
cur_magic[i] = 0;
|
||||||
|
}
|
||||||
stamp_group = 0; /* reset! */
|
stamp_group = 0; /* reset! */
|
||||||
font_scroll = 0;
|
font_scroll = 0;
|
||||||
magic_scroll = 0;
|
|
||||||
tool_scroll = 0;
|
tool_scroll = 0;
|
||||||
eraser_scroll = 0;
|
eraser_scroll = 0;
|
||||||
fill_scroll = 0;
|
fill_scroll = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue