-
Notifications
You must be signed in to change notification settings - Fork 5
/
entity__panel_remaps.cpp
executable file
·1645 lines (1322 loc) · 47.2 KB
/
entity__panel_remaps.cpp
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
/*
* entity_panel_remaps.cpp
*
* Created on: 7 nov. 2008
* Author: pat
*/
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/slider.h>
#include <wx/bmpbuttn.h>
#include "ob_editor.h"
#include "images__MyPalette.h"
#include "entity__enums.h"
#include "entity__globals.h"
#include "entity__MyAnimationZone.h"
//****************************************************
// PANEL ANIMS
//****************************************************
Panel_Remaps *panel_Remaps;
Panel_Remaps::Panel_Remaps( wxNotebook *onglets )
:Panel_withAnims( onglets )
{
Constructor();
}
void Panel_Remaps::Constructor()
{
// Could by use by subobjects
panel_Remaps = this;
curr_ind_remap = -1;
mode8bit = false;
// Some inits
entityAnimation_time = -1;
itState = 0;
//******************
//* MAIN SIZERS
//******************
//top level sizer
wxBoxSizer *sizer_main = new wxBoxSizer( wxVERTICAL );
//Top part of the panel
wxBoxSizer *sizer_top = new wxBoxSizer( wxHORIZONTAL );
sizer_main->Add( sizer_top, 1, wxALL | wxEXPAND);
wxBoxSizer *sizer_topLeft = new wxBoxSizer( wxHORIZONTAL );
sizer_top->Add( sizer_topLeft, 0, wxALL | wxEXPAND);
wxBoxSizer *sizer_scrollWndFrameProps = new wxBoxSizer( wxVERTICAL );
sizer_top->Add( sizer_scrollWndFrameProps, 0, wxALL | wxEXPAND);
wxBoxSizer *sizer_topRight = new wxBoxSizer( wxVERTICAL );
sizer_top->Add( sizer_topRight, 1, wxALL | wxEXPAND );
//Bottom part of the panel
wxSizer *sizer_bottom = new wxBoxSizer( wxHORIZONTAL );
sizer_main->Add( sizer_bottom, 0, wxALL | wxEXPAND );
//******************
//* OBJECTS
//******************
//**************************
// LIST OF ANIMS
//**************************
list_Anims = new wListAnims(this);
list_Anims->SetMinSize( wxSize(150,50));
sizer_topLeft->Add( list_Anims, 0, wxALL |wxEXPAND );
//**************************
// CENTER PANEL
//**************************
scrollPanel = new AScrollPanel( this );
sizer_scrollWndFrameProps->Add( scrollPanel, 1, wxALL, 0 );
wxBoxSizer *sizer_topmiddle = new wxBoxSizer( wxVERTICAL );
// int fix_spacer_height = 12;
//**************************
// Remaps drop-down box
//**************************
sizer_remaps_choice = new wxBoxSizer( wxHORIZONTAL );
sizer_topmiddle->Add( sizer_remaps_choice, 0, wxALL | wxEXPAND );
txt_remaps = new wxStaticText( scrollPanel, wxID_ANY, wxT("Remap :" ));
sizer_remaps_choice->Add( txt_remaps, 0, wxALIGN_CENTER | wxALL , 4 );
wxString lst_choices[] = {};
choiceBox_remaps = new wxChoice( scrollPanel, REMAP_CHOICE, wxDefaultPosition, wxDefaultSize
, t_size_of(lst_choices), lst_choices);
choiceBox_remaps->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(Panel_Remaps::EvtRemapChange), NULL, this);
sizer_remaps_choice->Add( choiceBox_remaps, 0, wxALL, 4 );
sizer_remaps_choice->AddSpacer( 20 );
chckbx_8bit = new wxCheckBox(scrollPanel,B_8BIT, wxT("8Bit-Mode"),
wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
chckbx_8bit->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED , wxCommandEventHandler(Panel_Remaps::Evt8BitModeChange), new wxVariant((long) B_BLOK), this);
chckbx_8bit->MoveAfterInTabOrder( choiceBox_remaps );
sizer_remaps_choice->Add( chckbx_8bit, 1, wxALIGN_CENTER | wxALL );
wxBitmapButton *help_butt = new wxBitmapButton( scrollPanel, ID_HELP_REMAPS,
wxBitmap( wxImage( GetRessourceFile_String(wxT("help.png")))));
help_butt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this);
sizer_remaps_choice->Add( help_butt, 0, wxALL, 2 );
//**************************
// Butttons new/rename/del
//**************************
wxGridSizer *sizer_edit_btns = new wxGridSizer( 1, 3, 5, 5 );
sizer_topmiddle->Add( sizer_edit_btns, 0, wxTOP | wxBOTTOM | wxEXPAND, 10 );
//---------------------
// New Remap
wxButton *btn_new_remap = new wxButton(scrollPanel, ID_NEW_REMAP, wxT("New"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_new_remap->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_edit_btns->Add( btn_new_remap, 0, wxALL | wxEXPAND, 5 );
//---------------------
// Rename Remap
btn_rename_remap = new wxButton(scrollPanel, ID_RENAME_REMAP, wxT("Rename"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_rename_remap->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_edit_btns->Add( btn_rename_remap, 0, wxALL | wxEXPAND, 5 );
//---------------------
// Delete Remap
btn_delete_remap = new wxButton(scrollPanel, ID_DELETE_REMAP, wxT("Delete"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_delete_remap->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_edit_btns->Add( btn_delete_remap, 0, wxALL | wxEXPAND, 5 );
//**************************
// Paths
//**************************
wxStaticBoxSizer *sizer_PATHS = new wxStaticBoxSizer( wxVERTICAL, scrollPanel, wxT("Paths") );
staticBoxPath = sizer_PATHS->GetStaticBox();
wxColour _colour;
sizer_topmiddle->Add( sizer_PATHS, 0, wxRIGHT | wxEXPAND );
//---------------------
// BASE IMAGE
//---------------------
wxBoxSizer *sizer_baseimg = new wxBoxSizer( wxHORIZONTAL );
sizer_PATHS->Add( sizer_baseimg, 0 , wxEXPAND );
txt_base_img = new wxStaticText( scrollPanel, wxID_ANY, wxT("Base"), wxPoint(wxDefaultCoord,8), wxSize( 80, wxDefaultCoord) );
sizer_baseimg->Add( txt_base_img, 0, wxALL, 4 );
txtctrl_imgBase = new wxTextCtrl(scrollPanel, IMG_BASE, wxString(),wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_RIGHT );
txtctrl_imgBase->Connect( wxEVT_COMMAND_TEXT_ENTER , wxCommandEventHandler(Panel_Remaps::EvtCommand), NULL, this);
txtctrl_imgBase->SetInsertionPointEnd();
txtctrl_imgBase->MoveAfterInTabOrder( chckbx_8bit );
sizer_baseimg->Add( txtctrl_imgBase, 1, wxEXPAND );
pickerBaseImg = new wxFilePickerCtrl( scrollPanel, ID_PICKER_BASE_IMG,
dataDirPath.GetFullPath(), wxT("Select the image base for the remap"), wxT("*.*"),
wxDefaultPosition, wxDefaultSize, wxFLP_OPEN | wxFLP_FILE_MUST_EXIST );
pickerBaseImg->Connect(wxEVT_COMMAND_FILEPICKER_CHANGED , wxFileDirPickerEventHandler(Panel_Remaps::EvtPickerImgBaseChg), NULL, this);
pickerBaseImg->SetMaxSize( wxSize(30, wxDefaultCoord ));
pickerBaseImg->SetInitialSize(wxSize(30, 30 ));
sizer_baseimg->Add( pickerBaseImg, 0, wxALL );
/*
//---------------------
// Create base imgage for remaps button
wxButton *btn_create_base = new wxButton(scrollPanel, ID_CREATE_BASEIMG_REMAP, "Create a base for Remaps" );
btn_create_base->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_PATHS->Add( btn_create_base, 0, wxALL | wxEXPAND, 5 );
*/
//---------------------
// DEST IMG
//---------------------
wxBoxSizer *sizer_dest_img = new wxBoxSizer( wxHORIZONTAL );
sizer_PATHS->Add( sizer_dest_img, 1 , wxEXPAND );
txt_result = new wxStaticText( scrollPanel, wxID_ANY, wxT("Result"), wxPoint(wxDefaultCoord,8), wxSize( 80, wxDefaultCoord) );
sizer_dest_img->Add( txt_result, 0, wxALL, 4 );
txtctrl_destimg = new wxTextCtrl(scrollPanel, IMG_DEST, wxString(),wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER | wxTE_RIGHT );
txtctrl_destimg->Connect( wxEVT_COMMAND_TEXT_ENTER , wxCommandEventHandler(Panel_Remaps::EvtCommand), NULL, this);
txtctrl_destimg->SetInsertionPointEnd();
txtctrl_destimg->MoveAfterInTabOrder( txtctrl_imgBase );
sizer_dest_img->Add( txtctrl_destimg, 1, wxEXPAND );
pickerDestImg = new wxFilePickerCtrl( scrollPanel, ID_PICKER_DEST_IMG,
dataDirPath.GetFullPath(), wxT("Select the sound for this frame"), wxT("*.*"),
wxDefaultPosition, wxDefaultSize, wxFLP_OPEN | wxFLP_FILE_MUST_EXIST );
pickerDestImg->Connect(wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler(Panel_Remaps::EvtPickerImgDestChg), NULL, this);
pickerDestImg->SetMaxSize( wxSize(30, wxDefaultCoord ));
pickerDestImg->SetInitialSize(wxSize(30, 30 ));
sizer_dest_img->Add( pickerDestImg, 0, wxALL );
//**************************
// TOOLS BUTTONS
//**************************
sizer_tools_btns = new wxGridSizer( 2, 2, 0, 0 );
sizer_topmiddle->Add( sizer_tools_btns, 0, wxTOP | wxBOTTOM | wxEXPAND, 10 );
//---------------------
// Guess the colours from the current frame
btn_guess_cols = new wxButton(scrollPanel, ID_GUESS_COLORS, wxT("Guess Cols"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_guess_cols->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_tools_btns->Add( btn_guess_cols, 0, wxALL | wxEXPAND, 5 );
//---------------------
// Save the remap
btn_save_remap = new wxButton(scrollPanel, ID_SAVE_REMAP, wxT("Save"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_save_remap->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_tools_btns->Add( btn_save_remap, 0, wxALL | wxEXPAND, 5 );
//---------------------
// Set the selection to the selected colors
btn_set_sel = new wxButton(scrollPanel, ID_SET_SEL_COLS, wxT("Set Selects"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_set_sel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_tools_btns->Add( btn_set_sel, 0, wxALL | wxEXPAND, 5 );
//---------------------
// UnSet the selection
btn_unset_sel = new wxButton(scrollPanel, ID_UNSET_SEL_COLS, wxT("UnSet them"), wxDefaultPosition, wxSize( wxDefaultCoord, 30) );
btn_unset_sel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_tools_btns->Add( btn_unset_sel, 0, wxALL | wxEXPAND, 5 );
//**************************
// Palette Object
//**************************
paletteCtrl = new MyPaletteCtrl( scrollPanel );
sizer_topmiddle->Add(paletteCtrl, 0, wxALL | wxEXPAND );
//**************************
// MODIF COLORS SLIDERS
//**************************
sizer_HSV = new wxStaticBoxSizer( wxVERTICAL, scrollPanel, wxT("Colours Modifications") );
sizer_topmiddle->Add( sizer_HSV, 0, wxTOP | wxEXPAND, 10 );
//---------------------
// Label RGB
txt_RGB = new wxStaticText( scrollPanel, wxID_ANY, wxT("Red / Green / Blue" ));
sizer_HSV->Add( txt_RGB, 0, wxALIGN_CENTER | wxTOP, 10 );
//---------------------
// Red
red_ctrl = new wxSlider( scrollPanel, ID_RED_CTRL, 0, -100, 100 );
red_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
red_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
red_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
red_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
red_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
red_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( red_ctrl, 0, wxTOP | wxEXPAND, 10 );
//---------------------
// Green
green_ctrl = new wxSlider( scrollPanel, ID_GREEN_CTRL, 0, -100, 100 );
green_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
green_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
green_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
green_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
green_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
green_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( green_ctrl, 0, wxALL | wxEXPAND, 1 );
//---------------------
// Blue
blue_ctrl = new wxSlider( scrollPanel, ID_BLUE_CTRL, 0, -100, 100 );
blue_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
blue_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
blue_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
blue_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
blue_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
blue_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( blue_ctrl, 0, wxALL | wxEXPAND, 1 );
//---------------------
// Label HSV
txt_HSL = new wxStaticText( scrollPanel, wxID_ANY, wxT("Hue / Saturation / Brightness") );
sizer_HSV->Add( txt_HSL, 0, wxALIGN_CENTER | wxTOP, 10 );
//---------------------
// Hue
hue_ctrl = new wxSlider( scrollPanel, ID_HUE_CTRL, 0, -50, 50 );
hue_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
hue_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
hue_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
hue_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
hue_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
hue_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( hue_ctrl, 0, wxTOP | wxEXPAND, 10 );
//---------------------
// Saturation
sat_ctrl = new wxSlider( scrollPanel, ID_SAT_CTRL, 0, -50, 50 );
sat_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sat_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sat_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sat_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sat_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sat_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( sat_ctrl, 0, wxALL | wxEXPAND, 1 );
//---------------------
// Luz
lum_ctrl = new wxSlider( scrollPanel, ID_LUM_CTRL, 0, -50, 50 );
lum_ctrl->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
lum_ctrl->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
lum_ctrl->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
lum_ctrl->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
lum_ctrl->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
lum_ctrl->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler(Panel_Remaps::EvtSlidersChg), NULL, this );
sizer_HSV->Add( lum_ctrl, 0, wxALL | wxEXPAND, 1 );
//**************************
// BUTTONS APPLY/CANCEL
//**************************
wxGridSizer *sizer_btns_AppCanc = new wxGridSizer( 1, 2, 5, 5 );
sizer_topmiddle->Add( sizer_btns_AppCanc, 0, wxALL |wxEXPAND);
btn_apply_cols = new wxButton(scrollPanel, ID_APPLY_COLORS, wxT("Apply") );
btn_apply_cols->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_btns_AppCanc->Add( btn_apply_cols, 1, wxALL | wxEXPAND, 5 );
btn_cancel_cols = new wxButton(scrollPanel, ID_CANCEL_COLORS, wxT("Cancel") );
btn_cancel_cols->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this );
sizer_btns_AppCanc->Add( btn_cancel_cols, 1, wxALL | wxEXPAND, 5 );
//**************************
// Frame View
//**************************
wxBoxSizer *sizer_btns_Zoom = new wxBoxSizer( wxHORIZONTAL );
sizer_topRight->Add(sizer_btns_Zoom, 0,wxEXPAND );
sizer_btns_Zoom->AddStretchSpacer();
wxBitmapButton *butt_Zoom_M = new wxBitmapButton( this, ID_ZOOM_M,
wxBitmap( wxImage( GetRessourceFile_String(wxT("zoom-out.png")))));
butt_Zoom_M->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this);
sizer_btns_Zoom->Add( butt_Zoom_M, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2 );
wxBitmapButton *butt_Zoom_P = new wxBitmapButton( this, ID_ZOOM_P,
wxBitmap( wxImage( GetRessourceFile_String(wxT("zoom-in.png")))));
butt_Zoom_P->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Panel_Remaps::EvtButtonClick), NULL, this);
sizer_btns_Zoom->Add( butt_Zoom_P, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2 );
sizer_btns_Zoom->AddStretchSpacer();
frameView = new MyRemapViewerCtrl( this );
sizer_topRight->Add(frameView, 1, wxEXPAND );
//**************************
// LIST OF FRAMES
//**************************
wList_frames = new wListFrames( this );
sizer_bottom->Add( wList_frames, 1, wxALL );
//**************************
// INITIALISATIONS
//**************************
scrollPanel->SetSizer( sizer_topmiddle);
SetSizer( sizer_main );
wList_frames->AssociateToListAnims( list_Anims);
list_Anims->AssociateToListFrame( wList_frames);
Layout();
}
//*********************************************************************
Panel_Remaps::~Panel_Remaps()
{
}
//*********************************************************************
void Panel_Remaps::Refresh()
{
SetSize( GetSize() );
Panel_withAnims::Refresh();
frameView->UpdateFrames();
}
//*********************************************************************
void Panel_Remaps::ReloadGifs()
{
Panel_withAnims::ReloadGifs();
frameView->UpdateFrames();
}
//*********************************************************************
void Panel_Remaps::Reload()
{
Panel_withAnims::Refresh();
wxString prev_selection = choiceBox_remaps->GetStringSelection();
paletteCtrl->Reset(false);
if( entity == NULL)
return;
if( mode8bit )
SwitchTo8BitMode();
else
SwitchTo16BitMode();
// Try to restore previous selection
for( size_t i = 0; i < choiceBox_remaps->GetCount(); i++)
{
wxString choice_item = choiceBox_remaps->GetString( i );
if( choice_item.Upper() == prev_selection.Upper() )
{
choiceBox_remaps->SetSelection(i);
DoRemapSelectionChange();
}
}
frameView->UpdateFrames();
}
//*********************************************************************
void Panel_Remaps::OnActivate()
{
Panel_withAnims::OnActivate();
if( b_entity_has_change )
{
paletteCtrl->Reset();
GessBitMode();
}
Refresh();
}
//*********************************************************************
void Panel_Remaps::GessBitMode()
{
if( entity == NULL )
return;
ob_object* _thePalette = entity->obj_container->GetSubObject( wxT("palette") );
if( _thePalette != NULL && entity->GetProperty( wxT("alternatepal") ) != NULL )
SwitchTo16BitMode();
else
SwitchTo8BitMode();
}
//*********************************************************************
void Panel_Remaps::InitRemapsChoices()
{
choiceBox_remaps->Clear();
// Check 16bit mode
if( !mode8bit )
{
ob_object* _thePalette = entity->GetProperty( wxT("palette") );
size_t nb_alterpal = 0;
ob_object** _alterpals = NULL;
if( _thePalette != NULL )
_alterpals = entity->GetSubObjectS(wxT("alternatepal"),nb_alterpal);
// if 16 bits mod exist choose it
if( nb_alterpal > 0 )
{
for( size_t i = 0; i < nb_alterpal; i++ )
{
// Get the comment for this remap
wxString _name = _alterpals[i]->GetComment();
if( _name == wxString() )
_name = wxT("alternatepal ") + IntToStr( i );
_name = _name.Trim().Trim(true);
if( _name.Left(1) == wxT("#") )
_name = _name.Right( _name.Len() - 1 );
_name = _name.Left(15);
choiceBox_remaps->Append( _name );
}
delete[] _alterpals;
}
}
else
{
// 8bit mode
size_t nb_remaps;
ob_object** _remaps = entity->GetSubObjectS( wxT("remap"), nb_remaps );
for( size_t i = 0; i < nb_remaps; i++ )
{
// Get the comment for this remap
wxString _name = _remaps[i]->GetComment();
if( _name == wxString() )
_name = wxT("remap ") + IntToStr( i );
_name = _name.Trim().Trim(true);
if( _name.Left(1) == wxT("#") )
_name = _name.Right( _name.Len() - 1 );
_name = _name.Left(15);
choiceBox_remaps->Append( _name );
}
if( _remaps != NULL )
delete[] _remaps;
}
if( choiceBox_remaps->GetCount() > 0 )
{
choiceBox_remaps->SetSelection(0);
curr_ind_remap = 0;
}
else
curr_ind_remap = -1;
DoRemapSelectionChange();
}
//*********************************************************************
void Panel_Remaps::SwitchTo8BitMode()
{
// Check the 8bit box
chckbx_8bit->SetValue( true );
mode8bit = true;
paletteCtrl->mode8bit = true;
// Set some statictext
txt_base_img->SetLabel( wxT("Base") );
txt_result->SetLabel(wxT("Result") );
btn_guess_cols->SetLabel( wxT("Create Base") );
//Hide some buttons
EnableHSV( false );
// Init remap choices
InitRemapsChoices();
sizer_tools_btns->RecalcSizes();
/* wxSizeEvent event;
scrollPanel->EvtSize( event );*/
scrollPanel->SetSize(scrollPanel->GetSize());
scrollPanel->Refresh();
}
//*********************************************************************
void Panel_Remaps::SwitchTo16BitMode()
{
// Set the 8bit box
chckbx_8bit->SetValue( false );
mode8bit = false;
paletteCtrl->mode8bit = false;
// Set some statictext
txt_base_img->SetLabel( wxT("Palette") );
txt_result->SetLabel( wxT("AlterPal") );
btn_guess_cols->SetLabel( wxT("Guess Cols") );
// Show all HSB controls
EnableHSV( true );
ResetHSV();
// Init remap choices
InitRemapsChoices();
sizer_tools_btns->Layout();
/* wxSizeEvent event;
scrollPanel->EvtSize( event );*/
scrollPanel->SetSize(scrollPanel->GetSize());
scrollPanel->Refresh();
}
//*********************************************************************
void Panel_Remaps::EnableHSV( bool b_enable )
{
// Show/Hide some tools Buttons
btn_set_sel->Show(b_enable);
btn_unset_sel->Show(b_enable);
// Hide all HSV
sizer_HSV->GetStaticBox()->Show( b_enable );
txt_HSL->Show( b_enable );
hue_ctrl->Show( b_enable );
sat_ctrl->Show( b_enable );
lum_ctrl->Show( b_enable );
red_ctrl->Show( b_enable );
txt_RGB->Show( b_enable );
green_ctrl->Show( b_enable );
blue_ctrl->Show( b_enable );
btn_apply_cols->Show( b_enable );
btn_cancel_cols->Show( b_enable );
}
//*********************************************************************
void Panel_Remaps::EvtRemapChange( wxCommandEvent& event )
{
if( paletteCtrl->isChanged && curr_ind_remap >= 0 )
{
//Make the user sure to abort his modifications
int res = wxMessageBox( wxT("Change have been made in the current palette.\n"
"Sure to cancel them ?")
, wxT("Question"), wxYES_NO | wxICON_INFORMATION, this );
if( res != wxYES )
{
// Reselect previous selected
choiceBox_remaps->SetSelection( curr_ind_remap );
return;
}
}
DoRemapSelectionChange();
}
//*********************************************************************
void Panel_Remaps::DoRemapSelectionChange( bool b_quiet )
{
if( entity == NULL )
{
wxMessageBox( wxT("No entity selected !!!"), wxT("GROSS PROBLEM"), wxOK | wxICON_INFORMATION, this );
paletteCtrl->Reset();
scrollPanel->Enable( false );
curr_remap = NULL;
return;
}
scrollPanel->Enable( true );
ResetHSV();
//******************************
// Get the new remap object
int ind_remap = choiceBox_remaps->GetSelection();
if( ind_remap == wxNOT_FOUND )
{
paletteCtrl->Reset();
curr_remap = NULL;
EnableEditingTheRemap(2);
Refresh();
return;
}
size_t nb_remap = 0;
ob_object** _remaps = NULL;
if( mode8bit )
_remaps = entity->GetSubObjectS( wxT("remap"), nb_remap );
else
_remaps = entity->GetSubObjectS( wxT("alternatepal"), nb_remap );
if( ind_remap < 0 || ind_remap >= (int) nb_remap )
{
choiceBox_remaps->SetSelection( wxNOT_FOUND );
curr_remap = NULL;
wxMessageBox( wxT("This remap does not exist !!!"), wxT("GROSS PROBLEM"), wxOK | wxICON_INFORMATION, this );
EnableEditingTheRemap(1);
Refresh();
if( _remaps != NULL )
delete[] _remaps;
return;
}
curr_remap = _remaps[ind_remap];
delete[] _remaps;
curr_ind_remap = ind_remap;
//******************************
// Fill the fields of paths
wxString _basePath;
wxString _destPath;
if( mode8bit )
{
_basePath = curr_remap->GetToken(0);
_destPath = curr_remap->GetToken(1);
}
else
{
_basePath = entity->obj_container->GetSubObject_Token( wxT("palette") );
_destPath = curr_remap->GetToken(0);
}
txtctrl_imgBase->SetValue( _basePath );
if( _basePath != wxString() )
pickerBaseImg->SetPath( GetObFile(_basePath).GetFullPath() );
_basePath = GetObFile(_basePath).GetFullPath();
txtctrl_destimg->SetValue( _destPath );
if( _destPath != wxString() )
pickerDestImg->SetPath( GetObFile(_destPath).GetFullPath() );
_destPath = GetObFile(_destPath).GetFullPath();
//******************************
// Try to Load the palette
if( DoChangeImgBase( b_quiet, false ) )
DoChangeImgDest( b_quiet, false );
paletteCtrl->DeselectEveryThing();
Refresh();
}
void Panel_Remaps::DoCreateBase()
{
// Make the user sure
int res = wxMessageBox( wxT("This will overwrite the current base image.\n"
"It will be replaced by a copy image,\n"
"at which will be added all the missing colors of the palette"
"Sure to do this ?")
, wxT("Question"), wxYES_NO | wxICON_INFORMATION, this );
if( res == wxYES )
{
if( paletteCtrl->theSourceImg == NULL || !paletteCtrl->theSourceImg->IsOk() )
{
wxMessageBox( wxT("Invalide base image for the operation ")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return;
}
// Get the base name
// Ask for the name
wxFileDialog _dialog(this, wxT("Choose a file for the base img for remaps"),dataDirPath.GetFullPath() );
int response = _dialog.ShowModal();
if( response != wxID_OK )
return;
wxString fn_base = _dialog.GetPath();
// Check if it's a valid ob project pa
wxString str_path = Convert_To_Ob_Path( fn_base );
if( str_path == wxString() )
{
wxMessageBox( wxT("Can't use this file.\nIs it really in the project data Directory ?"), wxT("Error"), wxOK | wxICON_INFORMATION, this );
return;
}
// Draw each palette element on the base image
int _y=0;
int _x=-1;
for( int i = 0; i < paletteCtrl->nb_elts ; i++)
{
_x++;
// Ok
if( paletteCtrl->theSourceImg->SetPixel( _x, _y, i ) )
continue;
// must go to line
_y++;
_x=-1;
i--;
}
//Save the base
if( ! paletteCtrl->theSourceImg->SaveAs( fn_base ) )
{
wxMessageBox( wxT("Cannot save the resulted image ")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return;
}
// Set the new base to the textcontrol
txtctrl_imgBase->SetValue( str_path );
// Refresh the palette
DoChangeImgBase(true);
return;
}
}
//*********************************************************************
void Panel_Remaps::Evt8BitModeChange( wxCommandEvent& event )
{
if( mode8bit != chckbx_8bit->GetValue() )
{
// Make the user sure
if( paletteCtrl->isChanged && curr_ind_remap >= 0 )
{
//Make the user sure to abort his modifications
int res = wxMessageBox( wxT("Change have been made in the current palette.\nSure to cancel them ?")
, wxT("Question"), wxYES_NO | wxICON_INFORMATION, this );
if( res != wxYES )
{
// Restore the previous state
chckbx_8bit->SetValue( mode8bit );
return;
}
}
paletteCtrl->DeselectEveryThing();
if( chckbx_8bit->GetValue() )
SwitchTo8BitMode();
else
SwitchTo16BitMode();
}
}
//*********************************************************************
void Panel_Remaps::EnableEditingTheRemap( int mode)
{
wxWindowList l_children = scrollPanel->GetChildren();
for ( wxWindowListNode *node = l_children.GetFirst(); node; node = node->GetNext() )
{
wxWindow *curr_child = node->GetData();
if( curr_child->GetId() != ID_NEW_REMAP
&& curr_child->GetId() != ID_RENAME_REMAP
&& curr_child->GetId() != ID_DELETE_REMAP
&& curr_child->GetId() != REMAP_CHOICE
&& curr_child->GetId() != IMG_BASE
&& curr_child->GetId() != ID_HELP_REMAPS
&& curr_child->GetId() != ID_PICKER_BASE_IMG
&& curr_child->GetId() != IMG_DEST
&& curr_child->GetId() != ID_PICKER_DEST_IMG
&& curr_child->GetId() != B_8BIT
&& curr_child != txt_base_img
&& curr_child != txt_result
&& curr_child != txt_remaps
&& curr_child != staticBoxPath
)
curr_child->Enable( mode == 0 );
}
bool b_enable_ext = (mode < 2);
btn_delete_remap->Enable( b_enable_ext);
btn_rename_remap->Enable( b_enable_ext );
txt_base_img->Enable( b_enable_ext );
txt_result->Enable( b_enable_ext );
txt_remaps->Enable( b_enable_ext );
choiceBox_remaps->Enable( b_enable_ext );
// btn_save_remap->Enable( b_enable_ext );
txt_base_img->Enable( b_enable_ext );;
txtctrl_imgBase->Enable( b_enable_ext );
pickerBaseImg->Enable( b_enable_ext );
txt_result->Enable( b_enable_ext);
txtctrl_destimg->Enable( b_enable_ext );
pickerDestImg->Enable( b_enable_ext );
}
//*********************************************************************
bool Panel_Remaps::EntityChanged()
{
return entity->changed;
}
//*********************************************************************
bool Panel_Remaps::Save_DoChecks()
{
// Check if there is a valid source img
if( ! paletteCtrl->b_init || paletteCtrl->theSourceImg == NULL || ! paletteCtrl->theSourceImg->IsOk())
{
wxMessageBox( wxT("There is no valide source Image for the remap ")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return false;
}
//Get the dest file
wxFileName dest_file = GetObFile( txtctrl_destimg->GetValue() );
// Checks Destination not specified
wxString str_fn = dest_file.GetFullPath();
if( str_fn == wxString() )
{
wxMessageBox( wxT("No Destination Image specified !!")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return false;
}
wxString _ext = dest_file.GetExt().Upper();
if( _ext != wxT("PNG") && _ext != wxT("GIF") )
{
wxMessageBox( wxT("The extension of the destination file is not GIF or PNG !!")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return false;
}
// Checks mismatch file types
if(
(_ext == wxT("PNG") && paletteCtrl->theSourceImg->type != pIMG_PNG )
||
(_ext == wxT("GIF") && paletteCtrl->theSourceImg->type != pIMG_GIF )
)
{
wxMessageBox( wxT("Source and destination Image haven't the same extension")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return false;
}
return true;
}
//*********************************************************************
bool Panel_Remaps::Save_16Bit_Remap()
{
if( ! Save_DoChecks() )
return false;
imgFile *srcImg = paletteCtrl->theSourceImg;
wxFileName dest_file = GetObFile( txtctrl_destimg->GetValue() );
// Save the previous palette of the source
MyPalette* prev_palette = srcImg->GetPalette();
if( prev_palette == NULL || !prev_palette->IsOk() )
{
wxMessageBox( wxT("Problem when saving the source palette !!")
, wxT("GROSS ProPlem"), wxOK | wxICON_INFORMATION, this );
if( prev_palette != NULL )
delete prev_palette;
return false;
}
// Apply the new palette to the source
if( ! srcImg->SetPalette( paletteCtrl->GetNewPalette() ))
{
wxMessageBox( wxT("Problem when setting the new palette !!")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
delete prev_palette;
return false;
}
//Save the image
bool res = srcImg->SaveAs( dest_file.GetFullPath());
// Restore the palette
srcImg->SetPalette( *prev_palette );
delete prev_palette;
if( ! res )
{
wxMessageBox( wxT("Problem when saving the resulting image !!")
, wxT("ProPlem"), wxOK | wxICON_INFORMATION, this );
return false;
}
paletteCtrl->isChanged = false;
return true;
}
//*********************************************************************
bool Panel_Remaps::Save_8Bit_Remap()
{
if( ! Save_DoChecks() )
return false;
imgFile *srcImg = paletteCtrl->theSourceImg;
wxFileName dest_file = GetObFile( txtctrl_destimg->GetValue() );
// Copy image Data
int srcImg_datas_size;
unsigned char *srcImg_datas = srcImg->GetDatas( srcImg_datas_size );
// Remap the image