-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathCELMENU.C
1218 lines (1108 loc) · 25.5 KB
/
CELMENU.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "errcodes.h"
#include "rastrans.h"
#include "render.h"
#include "jimk.h"
#include "broadcas.h"
#include "inks.h"
#include "celmenu.h"
#include "softmenu.h"
/* globals for cel menu functions */
Celmu_cb *cmcb;
/* seeme feelme */
extern void go_multi(), go_zoom_settings(), movefli_tool(),
qinks(), see_cur_ink();
/******* tools *******/
extern Errcode cel_paste_ptfunc(), cel_paint_ptfunc();
extern Errcode init_paint_ctool(), init_paste_ctool();
extern void exit_paint_ctool(), exit_paste_ctool();
extern Errcode pj_errdo_unimpl(); /* dummy returns Err_unimpl */
/* locals */
static void cel_scale_ptfunc(), cel_tcolor_ptfunc(), cel_rotate_ptfunc(),
cel_move_ptfunc();
void see_cel_minitime();
static Minitime_data celtime_data;
static Minitime_data cm_flitime_data;
static Errcode init_tcolor_ptool();
static void exit_refresh_cel();
static void mb_set_celtool();
/******* button sub groups for tools ****/
/***** paint (and) paste group sel *****/
static Button cmu_bluelast_sel = MB_INIT1(
NONEXT,
NOCHILD, /* children */
80, 9, 0,0, /* w,h,x,y */
NODATA, /* "Blue Last", */
ccorner_text, /* seeme */
toggle_bgroup, /* feelme */
NOOPT,
&vs.cm_blue_last, 1,
NOKEY,
MB_B_GHILITE, /* flags */
);
static void hang_bluelast(Button *b)
{
/* only if paint tool and not streamdraw */
b->children = &cmu_bluelast_sel; /* always hang children to do offsets */
hang_children(b);
if((vs.cur_cel_tool != CELPT_PAINT) || vs.cm_streamdraw)
{
b->children = NULL;
white_block(&cmu_bluelast_sel); /* clear where it would be */
}
}
static Button cmu_bluelast_hanger = MB_INIT1(
NONEXT,
&cmu_bluelast_sel, /* children */
80, 9, 90, 3, /* w,h,x,y */
NODATA,
hang_bluelast, /* feelme */
NOFEEL,
NOOPT,
NOGROUP,0,
NOKEY,
0, /* flags */
);
static void toggle_stream(Button *b)
{
toggle_bgroup(b);
draw_button(&cmu_bluelast_hanger);
}
static Button cmu_stream_sel = MB_INIT1(
&cmu_bluelast_hanger,
NOCHILD, /* children */
80, 9, 3, 3, /* w,h,x,y */
NODATA, /* "Stream", */
ccorner_text, /* seeme */
toggle_stream,
NOOPT,
&vs.cm_streamdraw, 1,
NOKEY,
MB_B_GHILITE, /* flags */
);
Button cmu_pa_group_sel = MB_INIT1(
NONEXT,
&cmu_stream_sel,
80, 9, 0, 0, /* w,h,x,y */
NODATA, /* datme */
NOSEE, /* seeme */
NOFEEL, /* feelme */
NOOPT,
NOGROUP,0,
NOKEY,
0, /* flags */
);
/****** move group sel ******/
static Button cmu_moveto_sel = MB_INIT1(
NONEXT,
NOCHILD, /* children */
80, 9, 3, 3, /* w,h,x,y */
NODATA, /* "To cursor", */
ccorner_text, /* seeme */
toggle_bgroup, /* feelme */
NOOPT,
&vs.cm_move_to_cursor, 1,
NOKEY,
MB_B_GHILITE, /* flags */
);
static Button cmu_move_group_sel = MB_INIT1(
NONEXT,
&cmu_moveto_sel, /* children */
80, 9, 0, 0, /* w,h,x,y */
NODATA, /* datme */
NOSEE, /* seeme */
NOFEEL, /* feelme */
NOOPT,
NOGROUP,0,
NOKEY,
0, /* flags */
);
static Pentool cel_scale_tool = PTOOLINIT1(
NONEXT,
NOTEXT, /* "Stretch", */
PTOOL_OPT,
CELPT_SCALE,
"",
NO_SUBOPTS,
NULL,
cel_scale_ptfunc,
&plain_ptool_cursor,
init_marqi_ctool, /* on install */
exit_marqi_ctool, /* on remove */
);
static Pentool cel_rotate_tool = PTOOLINIT1(
&cel_scale_tool,
NOTEXT, /* "Turn", */
PTOOL_OPT,
CELPT_ROTATE,
"",
NO_SUBOPTS,
NULL,
cel_rotate_ptfunc,
&plain_ptool_cursor,
init_marqi_ctool, /* on install */
exit_marqi_ctool, /* on remove */
);
static Pentool cel_move_tool = PTOOLINIT1(
&cel_rotate_tool,
NOTEXT, /* "Move", */
PTOOL_OPT,
CELPT_MOVE,
"",
&cmu_move_group_sel,
NULL,
cel_move_ptfunc,
&plain_ptool_cursor,
init_marqi_ctool, /* on install */
exit_marqi_ctool, /* on remove */
);
static Pentool cel_paste_tool = PTOOLINIT1(
&cel_move_tool,
NOTEXT, /* "Paste", */
PTOOL_OPT,
CELPT_PASTE,
"",
&cmu_pa_group_sel,
NULL,
cel_paste_ptfunc,
&plain_ptool_cursor,
init_paste_ctool, /* on install */
exit_paste_ctool, /* on remove */
);
static Pentool cel_paint_tool = PTOOLINIT1(
&cel_paste_tool,
NOTEXT, /* "Sprite", */
PTOOL_OPT,
CELPT_PAINT,
"",
&cmu_pa_group_sel,
NULL,
cel_paint_ptfunc,
&plain_ptool_cursor,
init_paint_ctool, /* on install */
exit_paint_ctool, /* on remove */
);
static Pentool cel_tcolor_tool = PTOOLINIT1(
&cel_paint_tool,
NOTEXT, /* "Set Key", */
PTOOL_OPT,
CELPT_TCOLOR,
"",
NO_SUBOPTS,
NULL,
cel_tcolor_ptfunc,
&plain_ptool_cursor,
init_tcolor_ptool, /* on install */
exit_refresh_cel, /* on remove */
);
#define FIRST_CEL_TOOL cel_tcolor_tool
/******* buttons *******/
static Optgroup_data opg = {
&vs.cur_cel_tool,
(Option_tool *)&FIRST_CEL_TOOL,
NULL,
};
static Button cmu_toolopts_sel = MB_INIT1(
NONEXT, /* next */
NOCHILD, /* children */
197, 29, 119, 26, /* w,h,x,y */
NOTEXT,
hang_toolopts, /* seeme */
NOFEEL,
NOOPT,
&opg,0,
NOKEY,
0, /* flags */
);
static void see_celtool_sel(Button *b)
{
set_button_disable(b,thecel == NULL);
see_option_name(b);
}
static Button cmu_tco_sel = MB_INIT1(
&cmu_toolopts_sel, /* next */
NOCHILD, /* children */
53, 9, 6, 46, /* w,h,x,y */
&cel_tcolor_tool, /* datme */
see_celtool_sel,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_TCOLOR,
NOKEY,
MB_GHILITE, /* flags */
);
static void see_draw_frames_option(Button *b)
{
set_button_disable(b,thecel == NULL
|| cmcb->no_draw_tools
|| (flix.hdr.frame_count <= 1));
see_option_name(b);
}
static Button cmu_pai_sel = MB_INIT1(
&cmu_tco_sel, /* next */
NOCHILD, /* children */
53, 9, 6, 26, /* w,h,x,y */
&cel_paint_tool, /* datme */
see_draw_frames_option,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_PAINT,
NOKEY,
MB_GHILITE, /* flags */
);
static void see_draw_option(Button *b)
{
set_button_disable(b,cmcb->no_draw_tools);
see_option_name(b);
}
static Button cmu_pas_sel = MB_INIT1(
&cmu_pai_sel, /* next */
NOCHILD, /* children */
53, 9, 6, 36, /* w,h,x,y */
&cel_paste_tool, /* datme */
see_draw_option,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_PASTE,
NOKEY,
MB_GHILITE, /* flags */
);
static Button cmu_sca_sel = MB_INIT1(
&cmu_pas_sel, /* next */
NOCHILD, /* children */
53, 9, 61, 46, /* w,h,x,y */
&cel_scale_tool, /* datme */
see_option_name,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_SCALE,
NOKEY,
MB_GHILITE, /* flags */
);
static Button cmu_rot_sel = MB_INIT1(
&cmu_sca_sel, /* next */
NOCHILD, /* children */
53, 9, 61, 36, /* w,h,x,y */
&cel_rotate_tool, /* datme */
see_option_name,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_ROTATE,
NOKEY,
MB_GHILITE, /* flags */
);
static Button cmu_mov_sel = MB_INIT1(
&cmu_rot_sel, /* next */
NOCHILD, /* children */
53, 9, 61, 26, /* w,h,x,y */
&cel_move_tool, /* datme */
see_option_name,
mb_set_celtool,
NOOPT,
&vs.cur_cel_tool,CELPT_MOVE,
NOKEY,
MB_GHILITE, /* flags */
);
static Sgroup1_data cel_sh1dat = {
&flxtime_data,
};
extern void qgrid_keep_undo(Button *b);
static Button cmu_grid_sel = MB_INIT1(
NONEXT,
NOCHILD, /* children */
44, 9, 267, 14, /* w,h,x,y */
NODATA, /* "Grid", */
ncorner_text,
toggle_bgroup,
qgrid_keep_undo,
&vs.use_grid,1,
NOKEY,
MB_B_GHILITE, /* flags */
);
extern void see_mask_button(Button *b);
extern void qmask_keep_undo(Button *b);
static Button cmu_mask_sel = MB_INIT1(
&cmu_grid_sel, /* next */
NOCHILD,
44, 9, 219, 14, /* w,h,x,y */
NODATA, /* "Mask", */
see_mask_button,
mb_toggle_mask,
qmask_keep_undo,
&vs.use_mask,1,
NOKEY,
MB_B_GHILITE,
);
static Button cmu_zpan_sel = MB_INIT1(
&cmu_mask_sel,
&zpan_cycle_group,
39, 9, 13, 14, /* w,h,x,y */
NODATA,
hang_children,
NOFEEL,
NOOPT,
NULL,0,
NOKEY,
0,
);
static void see_cel_frames(Button *b)
{
SHORT cnt;
if(thecel)
cnt = thecel->flif.hdr.frame_count;
else
cnt = 0;
b->datme = &cnt;
ncorner_short(b);
}
static Button cmu_frames_sel = MB_INIT1(
&cmu_zpan_sel,
NOCHILD, /* children */
34, 11, 277, 57, /* w,h,x,y */
NODATA, /* datme */
see_cel_frames,
NOFEEL,
NOOPT,
NOGROUP,0,
NOKEY,
MB_B_GHILITE, /* flags */
);
static Button cmu_minitime_sel = MB_INIT1(
&cmu_frames_sel,
NULL, /* children allocated in go_cel_menu() */
76,11,1,57,
NODATA, /* "Cel Frames:", */
see_cel_minitime,
NOFEEL,
NOOPT,
&celtime_data,0,
NOKEY,
0,
);
static Button cmu_minipal_sel = MB_INIT1(
&cmu_minitime_sel, /* next */
&minipal_sel,
93, 9, 119, 14, /* w,h,x,y */
NOTEXT,
hang_children,
NOFEEL,
NOOPT,
NULL,0,
NOKEY,
0
);
void qcel_inks(Button *b)
{
Pentool *pt;
/* we can't paste sprite in inks menu !!!! so don't do it */
pt = vl.ptool;
if(pt->ot.id == CELPT_PAINT)
{
vl.ptool = &null_pentool; /* fudge to prevent going into sprite mode
* when in inks menu */
flx_clear_olays(); /* clear cel if present */
qinks(b);
flx_draw_olays(); /* (re)draw cel (if present) */
vl.ptool = pt;
}
else
qinks();
}
static Button cmu_goinks_sel = MB_INIT1(
&cmu_minipal_sel,
NOCHILD,
53,9,238,3,
NOTEXT,
see_cur_ink,
qcel_inks,
qcel_inks,
&vs.ink_id,opq_INKID,
NOKEY,
MB_GHILITE,
);
static Button cmu_std1_sel = MB_INIT1(
&cmu_goinks_sel,
&std_head1_sel,
0, 0, 129, 3, /* w,h,x,y */
NOTEXT,
hang_children,
NOFEEL,
NOOPT,
&cel_sh1dat,0,
NOKEY,
0, /* flags */
);
Button cmu_common_sels = MB_INIT1(
&cmu_std1_sel,
NOCHILD,
0, 0, 5, 3, /* w,h,x,y */
NOTEXT,
NOSEE,
NOFEEL,
NOOPT,
NOGROUP,0,
NOKEY,
0, /* flags */
);
static Button cmu_undo_sel = MB_INIT1(
&cmu_mov_sel,
NOCHILD, /* children */
33, 9, 93, 3, /* w,h,x,y */
NODATA, /* "Undo", */
dcorner_text,
menu_doundo,
NOOPT,
NOGROUP,0,
'\b',
0, /* flags */
);
static Button cmu_title_sel = MB_INIT1(
&cmu_undo_sel,
&cmu_common_sels,
84, 9, 5, 3, /* w,h,x,y */
NODATA, /* "Anim Cel", */
hang_see_title,
feel_titlebar,
mb_menu_to_bottom,
&tbg_moveclose,0,
'q',
0, /* flags */
);
static void celmenu_credraw(void *dat, USHORT why)
{
redraw_head1_ccolor(&cmu_std1_sel);
zpan_ccycle_redraw(&cmu_zpan_sel);
draw_button(&cmu_minipal_sel);
}
static Redraw_node celmenu_rn = {
NULL,NULL, /* node */
celmenu_credraw,
NULL,
NEW_CCOLOR };
Menuhdr cel_menu = MENU_INIT0(
320,70,0,0, /* width, height, x, y */
CEL_MUID, /* id */
PANELMENU, /* type */
&cmu_title_sel, /* buttons */
SCREEN_FONT, /* font */
&menu_cursor, /* cursor */
seebg_white, /* seebg */
NULL, /* dodata */
NULL, /* domenu */
(MBPEN|MBRIGHT|KEYHIT), /* ioflags */
0, /* flags */
NULL, /* procmouse */
NULL, /* on_showhide */
NULL, /* cleanup */
);
static Smu_button_list cel_smblist[] = {
{ "title", &cmu_title_sel },
{ "bluelast", &cmu_bluelast_sel },
{ "stream", &cmu_stream_sel },
{ "moveto", &cmu_moveto_sel },
{ "grid", &cmu_grid_sel },
{ "mask", &cmu_mask_sel },
{ "cel_frames", &cmu_minitime_sel },
{ "undo", &cmu_undo_sel },
/* texts note first char is a 'T' */
{ "Tscale", &cel_scale_tool.ot.name },
{ "Tturn", &cel_rotate_tool.ot.name },
{ "Tmove", &cel_move_tool.ot.name },
{ "Tpaste", &cel_paste_tool.ot.name },
{ "Tsprite", &cel_paint_tool.ot.name },
{ "Tsetkey", &cel_tcolor_tool.ot.name },
};
void see_cel_minitime(Button *b)
{
black_label(b);
mb_hang_chiles_oset(b,b->width, 0);
}
static void redraw_ctool_buttons()
{
draw_button(&cmu_toolopts_sel);
}
static Errcode id_set_ctool(SHORT id)
{
return(set_curptool((Pentool *)id_find_option(
(Option_tool*)&FIRST_CEL_TOOL,id)));
}
static void id_set_cel_tool(SHORT id)
{
id_set_ctool(id);
vs.cur_cel_tool = vl.ptool->ot.id;
redraw_ctool_buttons();
}
static void mb_set_celtool(Button *b)
{
break_here();
id_set_ctool(b->identity);
mb_unhi_group(b);
vs.cur_cel_tool = vl.ptool->ot.id;
redraw_ctool_buttons();
mb_hi_group(b);
}
/***** tool functions ******/
static void exit_refresh_cel()
{
if(!thecel || flx_olays_hidden())
return;
cmu_unmarqi_cel();
draw_flicel(thecel,DRAW_DELTA,FORCE_CFIT);
}
static Boolean delta_marqi_cel()
{
ULONG time;
if(!thecel)
return(1); /* self remove, nothing to marqi */
if((time = pj_clock_1000()) >= cmcb->marqitime + DMARQI_MILLIS)
{
marqi_flicel(thecel,++cmcb->marqmod,NULL); /* re draw with ++mod */
cmcb->marqitime = time;
}
return(0);
}
void cmu_marqi_cel()
{
rem_waitask(&cmcb->mwt); /* just incase it is attached */
if(thecel)
{
init_waitask(&cmcb->mwt,delta_marqi_cel,NULL,0);
add_waitask(&cmcb->mwt);
/* just lots of safety for marqiing over existing marqi */
if(cmcb->marqi_save)
cmcb->marqi_save = NULL;
else
cmcb->marqi_save = cmcb->marqi_save_buf;
marqi_flicel(thecel,cmcb->marqmod,cmcb->marqi_save);
cmcb->marqi_save = cmcb->marqi_save_buf;
}
else
cmcb->marqi_save = NULL;
}
void cmu_unmarqi_cel()
{
rem_waitask(&cmcb->mwt); /* stop creepy re-drawing task */
if(thecel)
undo_flicel_marqi(thecel,cmcb->marqi_save);
cmcb->marqi_save = NULL;
}
Errcode init_marqi_ctool(Pentool *pt)
{
if(!flx_olays_hidden())
cmu_marqi_cel();
return(Success);
}
void exit_marqi_ctool(Pentool *pt)
{
cmu_unmarqi_cel();
}
/****** scale tool *****/
static void cel_scale_ptfunc(Pentool *pt,Wndo *w)
{
if(!thecel)
return;
save_celpos_undo();
cmu_unmarqi_cel();
vstretch_cel(1);
cmu_marqi_cel();
}
/**** rotate tool *****/
static void cel_rotate_ptfunc(Pentool *pt,Wndo *w)
{
if(!thecel)
return;
save_celpos_undo();
cmu_unmarqi_cel();
vrotate_cel(1);
cmu_marqi_cel();
}
/**** move tool *****/
static void cel_move_ptfunc(Pentool *pt,Wndo *w)
{
if(!thecel)
return;
save_celpos_undo();
cmu_unmarqi_cel();
mp_thecel(0,vs.cm_move_to_cursor?2:1);
cmu_marqi_cel();
}
/***** paint tool *****/
/*** see celpaste.c ****/
/***** paste tool *****/
/*** see celpaste.c ****/
/****** tcolor tool *******/
static Errcode draw_solid_tcolor(Pixel dcolor)
{
Errcode err;
BYTE ounder;
BYTE oclear;
Celcfit *ocfit;
Celcfit cfit;
int i;
/* save old render state */
ounder = vs.render_under;
oclear = vs.zero_clear;
vs.zero_clear = vs.render_under = 0;
ocfit = thecel->cfit;
init_celcfit(&cfit);
if(need_render_cfit(thecel->rc->cmap))
{
make_render_cfit(thecel->rc->cmap,&cfit,thecel->cd.tcolor);
}
else /* make a xlat for only the tcolor */
{
for(i = 0;i < COLORS;++i)
cfit.ctable[i] = i;
}
cfit.ctable[thecel->cd.tcolor] = dcolor;
thecel->cfit = &cfit;
err = draw_flicel(thecel,DRAW_FIRST,OLD_CFIT);
/* restore old render state */
thecel->cfit = ocfit;
vs.zero_clear = oclear;
vs.render_under = ounder;
return(err);
}
void break_there()
{
}
static Errcode init_tcolor_ptool(Pentool *pt)
{
Errcode err;
break_there();
/* if overlays hidden do not draw cel */
if(!thecel || flx_olays_hidden())
return(Success);
if((err = draw_solid_tcolor(vs.inks[1])) >= 0)
cmu_marqi_cel();
return(err);
}
void break_here()
{
}
static void cel_tcolor_ptfunc(Pentool *pt,Wndo *w)
{
Pixel color;
break_here();
cel_cancel_undo();
if(!thecel)
return;
if(!isin_fcel(thecel,icb.mx,icb.my))
return;
color = celt_color(icb.mx,icb.my);
set_flicel_tcolor(thecel,color);
draw_solid_tcolor(vs.inks[1]);
cmu_marqi_cel();
}
/**************** minitime cel frame control ************************/
static Errcode cm_celdraw(int marqi,int mode)
/* draw or redraw cel for current tool mode */
{
Errcode err;
if(vs.cur_cel_tool == CELPT_TCOLOR)
err = draw_solid_tcolor(vs.inks[1]);
else
err = draw_flicel(thecel,mode,NEW_CFIT);
if(err < 0)
return(err);
if(marqi)
cmu_marqi_cel();
}
static Errcode cm_deltadraw(int marqi)
{
if(thecel)
return(cm_celdraw(marqi,DRAW_DELTA));
}
static void mtcel_first_frame(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return;
seek_fcel_frame(*pcel, 0);
cm_deltadraw(1);
}
static void mtcel_prev_frame(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return;
seek_fcel_frame(cel, cel->cd.cur_frame - 1);
cm_deltadraw(1);
}
static void mtcel_playit(Flicel **pcel)
{
Errcode err;
Flicel *cel;
ULONG clock;
Fli_frame *cbuf;
if((cel = *pcel) == NULL)
return;
hide_mp();
hide_mouse();
cmu_unmarqi_cel();
if((err = pj_fli_cel_alloc_cbuf(&cbuf,cel->rc)) < 0)
goto error;
clock = pj_clock_1000();
for(;;)
{
clock += cel->flif.hdr.speed;
if (!wait_til(clock))
break;
if(cel->flif.hdr.frame_count > 1)
{
if((err = gb_seek_fcel_frame(cel, cel->cd.cur_frame + 1,
cbuf,FALSE)) < Success)
{
goto error;
}
if((err = cm_deltadraw(0)) < 0)
goto error;
}
}
err = Success;
error:
softerr(err,"cel_play");
cmu_marqi_cel();
show_mouse();
show_mp();
pj_free(cbuf);
}
static void mtcel_next_frame(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return;
seek_fcel_frame(cel, cel->cd.cur_frame + 1);
cm_deltadraw(1);
}
static void mtcel_last_frame(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return;
seek_fcel_frame(cel, cel->flif.hdr.frame_count - 1);
cm_deltadraw(1);
}
static SHORT mtcel_get_framenum(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return(0);
return(cel->cd.cur_frame);
}
static SHORT mtcel_get_framecount(Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return(1);
return(cel->flif.hdr.frame_count);
}
static void mtcel_seek_frame(SHORT ix, Flicel **pcel)
{
Flicel *cel;
if((cel = *pcel) == NULL)
return;
seek_fcel_frame(cel, ix);
cm_deltadraw(1);
}
static Minitime_data celtime_data = {
mtcel_first_frame, /* first frame */
mtcel_prev_frame, /* prev */
NULL, /* feel ix */
mtcel_next_frame, /* next */
mtcel_playit, /* play it */
mtcel_last_frame, /* last frame */
NULL, /* opt_all */
NULL, /* opt tsl_first */
mtcel_get_framenum, /* get_framenum */
mtcel_get_framecount,
NULL, /* clear_overlays */
NULL, /* draw_overlays */
mtcel_seek_frame, /* seek */
0, /* overlay clear stack */
&thecel, /* data */
};
/* fly playing functions */
void cm_erase_toolcel()
{
if(thecel)
{
cmu_unmarqi_cel();
unsee_flicel(thecel);
}
}
void cm_restore_toolcel()
/* draw cel and its marqi assuming cel is not present on screen */
{
if(thecel)
cm_celdraw(1,DRAW_FIRST);
}
static void ring_seek_fli(int ix)
{
int new_ix;
if(ix == (vs.frame_ix + 1))
{
new_ix = flx_ringseek(vb.pencel, vs.frame_ix, ix);
zoom_it();
save_undo();
}
else
{
save_undo();
new_ix = flx_ringseek(undof, vs.frame_ix, ix);
zoom_unundo();
}
if(new_ix >= 0)
vs.frame_ix = new_ix;
}
static void cm_firstfli()
{
if(cmcb->num_overlays)
ring_seek_fli(0);
else
first_frame();
}
static void cm_nextfli()
{
if(cmcb->num_overlays)
ring_seek_fli(vs.frame_ix + 1);
else
next_frame();
}
static void cm_prevfli()
{
if(cmcb->num_overlays)
ring_seek_fli(vs.frame_ix - 1);
else
prev_frame();
}
extern SHORT flx_get_framecount(), flx_get_frameix();
void go_time_menu(), mplayit(), last_frame(), cm_erase_toolcel(),
cm_restore_toolcel();
static char cel_off = 0; /* this brackets scrubs and flx seeks */
void cm_clear_olays()
{
if(cel_off == 0)
{
cmu_free_paste_undo(); /* kill paste undo and free mem */
cm_erase_toolcel();
}
++cel_off;
}
void cm_draw_olays()
{
if((--cel_off) == 0)
cm_restore_toolcel();
}
static Minitime_data cm_flitime_data = {
cm_firstfli, /* first frame */
cm_prevfli, /* prev */
go_time_menu, /* ix */
cm_nextfli, /* next */
mplayit, /* play it */
last_frame, /* last frame */
go_time_menu, /* opt_all */
NULL, /* opt tsl_first */
flx_get_frameix, /* get frame num */
flx_get_framecount, /* get framecount */
cm_clear_olays, /* clear_overlays */
cm_draw_olays, /* draw_overlays */
ring_seek_fli, /* seek */
NULL, /* data */
};
/********************************************/
static void cleanup_cel_menu()
{
free_buttonlist(&(cmu_minitime_sel.children));
if(thecel)
close_fcelio(thecel);
set_curptool(NULL); /* clean up tool with its exit function */
cmu_unmarqi_cel(); /* this is needed to insure the input creepy task
* is removed */
if(cmcb->undo_corrupted)
{