1 /*         ______   ___    ___
2  *        /\  _  \ /\_ \  /\_ \
3  *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
4  *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
5  *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
6  *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
7  *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
8  *                                           /\____/
9  *                                           \_/__/
10  *
11  *      Grabber plugin for managing FLIC animation objects.
12  *
13  *      By Shawn Hargreaves.
14  *
15  *      See readme.txt for copyright information.
16  */
17 
18 
19 #include <stdio.h>
20 
21 #include "allegro.h"
22 #include "allegro/internal/aintern.h"
23 #include "../datedit.h"
24 
25 
26 
27 /* creates a new FLIC object */
makenew_fli(long * size)28 static void *makenew_fli(long *size)
29 {
30    char *v = _AL_MALLOC(1);
31 
32    *v = 0;
33    *size = 1;
34 
35    return v;
36 }
37 
38 
39 
40 /* displays a FLIC object in the grabber object view window */
plot_fli(AL_CONST DATAFILE * dat,int x,int y)41 static void plot_fli(AL_CONST DATAFILE *dat, int x, int y)
42 {
43    textout_ex(screen, font, "Double-click in the item list to play it", x, y+32, gui_fg_color, gui_bg_color);
44 }
45 
46 
47 
48 /* callback to quit out of the FLI player */
fli_stopper(void)49 static int fli_stopper(void)
50 {
51    poll_mouse();
52 
53    if ((keypressed()) || (mouse_b))
54       return 1;
55    else
56       return 0;
57 }
58 
59 
60 
61 /* handles double-clicking on a FLIC object in the grabber */
view_fli(DATAFILE * dat)62 static int view_fli(DATAFILE *dat)
63 {
64    show_mouse(NULL);
65    clear_to_color(screen, gui_mg_color);
66    play_memory_fli(dat->dat, screen, TRUE, fli_stopper);
67    do {
68       poll_mouse();
69    } while (mouse_b);
70    clear_keybuf();
71    set_palette(datedit_current_palette);
72    show_mouse(screen);
73    return D_REDRAW;
74 }
75 
76 
77 
78 /* plugin interface header */
79 DATEDIT_OBJECT_INFO datfli_info =
80 {
81    DAT_FLI,
82    "FLI/FLC animation",
83    NULL,
84    makenew_fli,
85    NULL,
86    plot_fli,
87    view_fli,
88    NULL
89 };
90 
91 
92 
93 DATEDIT_GRABBER_INFO datfli_grabber =
94 {
95    DAT_FLI,
96    "fli;flc",
97    "fli;flc",
98    NULL,
99    NULL,
100    NULL
101 };
102 
103