forked from scp-fs2open/PCS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main_Panel.cpp
2041 lines (1674 loc) · 71.2 KB
/
Main_Panel.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
//****************************************************************************
// main_panel.cpp
// POF Constructor Suite
//****************************************************************************
/*
* $Logfile: /main_panel.cpp $
* $Revision: 1.32 $
* $Date: 2008/11/13 00:43:42 $
* $Author: kazan $
*
* $Log: Main_Panel.cpp,v $
* Revision 1.32 2008/11/13 00:43:42 kazan
* Just need to debug some issues with the new progress system, otherwise it's good
*
* Revision 1.31 2008/11/10 23:25:19 kazan
* more progress in transitioning
*
* Revision 1.30 2008/11/08 15:13:19 kazan
* Updated to wxWidgets 2.8.9 and switched from static linkage to DLL linkage.
*
* Revision 1.29 2008/05/15 22:15:56 kazan
* fix a crash
*
* Revision 1.28 2008/05/15 20:20:04 kazan
* *** empty log message ***
*
* Revision 1.27 2008/05/15 19:19:24 kazan
* Resolve #35, #64
* Maybe Resolve: #68, #61
*
* Revision 1.26 2008/05/15 17:43:58 kazan
* *** empty log message ***
*
* Revision 1.25 2008/02/11 13:56:23 kazan
* tweaks
*
* Revision 1.24 2008/02/09 23:01:40 kazan
* post-kaz_templates removal cleanup
*
* Revision 1.23 2008/02/09 22:32:58 kazan
* bye bye kaz_vector
*
* Revision 1.22 2008/02/09 22:28:08 kazan
* checkin before i do something drastic (pull out my templates - don't need them anymore)
*
* Revision 1.21 2008/02/09 17:54:27 kazan
* geometry can now be imported into an existing model
*
* Revision 1.20 2008/02/03 21:45:23 kazan
* Call main_panel::SignalModelChange("", true) to reset the view without changing the currently loaded model.
* New clears the model then uses the above
* Save calls the above at the end to refresh the view
* Leaving the Preferences dialog does as well
*
* Revision 1.19 2008/01/14 11:46:32 bobboau
* you forgot to disable VBO creation
*
* Revision 1.18 2008/01/12 18:02:23 bobboau
* revamped the renderer to draw with VBOs current implementation assumes the user's hardware suports them, which is not a good assumption, the old code is still present and will be used as a fall back for when VBOs don't work, but I haven't implemented the code to do the falling back yet, but it's trivial.
*
* also did a few other minor things.
*
* Revision 1.17 2008/01/11 06:24:09 bobboau
* fixing a spelling error, and modifyed the suggest box graphic a little
*
* Revision 1.16 2008/01/10 18:28:09 bobboau
* *** empty log message ***
*
* Revision 1.15 2007/07/24 22:50:23 bobboau
* added undo/redo functionality
*
* Revision 1.14 2007/07/18 17:57:47 bobboau
* made a plaform dependent fix for DevIL crashing when loading the nameplate.dds file, we could include some sort of error mesage or log it when this happens, from testing this fix will still cause the debugger to break on exception, so we will still be able to catch this, but to the user the file will simply fail to load.
* this is platform dependent and will need Special care for all suported platforms, currently it defaults to simple exception handeling when not in WIN32, but this will not usualy catch a divide by zero error.
*
* I also made some modifications to the renderer to make it behave more like FSO, it renders children first, and uses alpha blending, it can lead to some ugly results, but they will be just as ugly in FSO so it's good they get to see it.
*
* Revision 1.13 2007/07/15 17:35:16 bobboau
* fixed STUPIDEST BUG EVER
*
* Revision 1.12 2007/07/13 11:31:04 bobboau
* added auto-extraction and external loading of textures in VPs, and a user defined temp directory.
*
* Revision 1.11 2007/07/12 11:37:14 bobboau
* added shine mapping suport.
*
* Revision 1.10 2007/07/11 21:28:45 kazan
* purge bsp cache, openGL abstraction that doesn't function (thanks M$)
*
* Revision 1.9 2007/07/11 19:14:47 bobboau
* added a 'load textureexternaly' button, made the experimental BSP code the normal BSP code,
* the load texture feature uses a win32 specific comand because I couldn't find a good way to get it to work in a non-platform specific manner. I will continue to search for a better solution.
*
* and fixed a render (ships being drawn transparently when they shouldn't be) and crash (trying to update a progress bar that doesn't exsist) bug
*
* Revision 1.8 2007/07/11 14:09:33 kazan
* fix solid-view rendering bug, renable app modal progress dialogs during load
*
* Revision 1.7 2007/07/01 11:02:53 bobboau
* modified the way things are drawn and implemented a few minor features
*
* Revision 1.6 2007/06/30 04:14:51 bobboau
* commented out INSG tree item, untill a proper editor can be made for it.
*
* Revision 1.5 2007/06/29 21:00:26 bobboau
* added shield chunk "editor", doesn't actualy let you edit anything, but will display shield poly count and activate the rendering of shileds, which I also added.
*
* Revision 1.4 2007/06/29 20:15:42 bobboau
* added copy and delete functionality for subobjects, there are situations were some higherarchies might break this, we should realy consiter holding the subobject data in an actual tree.
*
* also added a set/get active chunk function to the gl canvas, and implemented a wireframe overlay for the currently selected subobject. (that only renders when you have a subobject selected in the tree/editor)
*
* Revision 1.3 2007/06/28 19:03:10 kazan
* add log headers
*
*
*/
#include"main_panel.h"
#include"chunk_editors.h"
#include"pcs2_filethread.h"
#include"VPReader.h"
#include<wx/mimetype.h>
#include<wx/process.h>
#include "AsyncProgress.h"
#include"selected.xpm"
#include"unselected.xpm"
#include"top_level_selected.xpm"
#include"top_level_unselected.xpm"
#include"selected_open.xpm"
#include"unselected_open.xpm"
#include"top_level_selected_open.xpm"
#include"top_level_unselected_open.xpm"
#include"dragable_selected.xpm"
#include"dragable_unselected.xpm"
#include"dragable_selected_open.xpm"
#include"dragable_unselected_open.xpm"
#include "matrix3d.h"
#include<wx/filename.h>
#include <wx/progdlg.h>
#include <wx/imaglist.h>
#include <wx/notebook.h>
#include <map>
#include <algorithm>
#define TREE_SEL 0
#define TREE_UNSEL 1
#define TREE_NOSEL 2
#define TREE_NOUNSEL 3
#define TREE_SEL_OP 4
#define TREE_UNSEL_OP 5
#define TREE_NOSEL_OP 6
#define TREE_NOUNSEL_OP 7
#define TREE_DR_SEL 8
#define TREE_DR_UNSEL 9
#define TREE_DR_SEL_OP 10
#define TREE_DR_UNSEL_OP 11
//ShellExecute(NULL, _T("open"), <filename that you want to open>, NULL, NULL, SW_SHOWNORMAL);
main_panel::main_panel(wxFrame* parent)
:wxPanel(parent,-1,wxPoint(0,0)),dragged_id(NULL),control_panel(NULL),pstatus(parent->GetStatusBar()),myParent(parent),pgauge(NULL),rebuilding_tree(false),internal_selection(false), threaded_prog_bar_readers(0), should_delete_threaded_prog_bar(false)
{
gprog = NULL;
threaded_prog_bar = NULL;
UseThreadedProgBar = true;
//+++++++++start status bar stuff
int x = parent->GetSize().x;
// size the statusbar fields
int widths[3];
isDestroyed = false;
// 10%, 95%, 5%
widths[0] = int(float(x)*0.15f);
widths[1] = int(float(x)*0.70f);
widths[2] = int(float(x)*0.15f);
pstatus->SetFieldsCount(3, widths);
pgauge = new wxGauge(pstatus, -1, 100,
wxPoint(widths[0]+5, 3),
wxSize(widths[1], 17),
wxGA_PROGRESSBAR | wxGA_SMOOTH);
//+++++++++end status bar stuff
wxGridSizer*sizer = new wxGridSizer(1,1,0,0);
//the main spliter, holding the tree on the left and the second spliter on the right
split1 = new wxSplitterWindow(this,-1,wxPoint(0,0),wxDefaultSize,wxSP_LIVE_UPDATE);
split1->SetSashSize(3);
//the tree
navigation_panel = new wxTreeCtrl(split1,-1,wxDefaultPosition,wxDefaultSize,wxTR_HIDE_ROOT|wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT);
wxImageList*IL = new wxImageList(16, 16, true, 2);
// wxImageList*IL = new wxImageList();
wxBitmap unsel(unselected);
unsel.SetMask(new wxMask(unsel,*wxGREEN));
wxBitmap sel(selected);
sel.SetMask(new wxMask(sel,*wxGREEN));
wxBitmap nosel(top_level_selected);
nosel.SetMask(new wxMask(nosel,*wxGREEN));
wxBitmap noselunsel(top_level_unselected);
noselunsel.SetMask(new wxMask(noselunsel,*wxGREEN));
wxBitmap unsel_op(unselected_open);
unsel_op.SetMask(new wxMask(unsel_op,*wxGREEN));
wxBitmap sel_op(selected_open);
sel_op.SetMask(new wxMask(sel_op,*wxGREEN));
wxBitmap nosel_op(top_level_selected_open);
nosel_op.SetMask(new wxMask(nosel_op,*wxGREEN));
wxBitmap noselunsel_op(top_level_unselected_open);
noselunsel_op.SetMask(new wxMask(noselunsel_op,*wxGREEN));
wxBitmap dr_unsel(dragable_unselected);
dr_unsel.SetMask(new wxMask(dr_unsel,*wxGREEN));
wxBitmap dr_sel(dragable_selected);
dr_sel.SetMask(new wxMask(dr_sel,*wxGREEN));
wxBitmap dr_unsel_op(dragable_unselected_open);
dr_unsel_op.SetMask(new wxMask(dr_unsel_op,*wxGREEN));
wxBitmap dr_sel_op(dragable_selected_open);
dr_sel_op.SetMask(new wxMask(dr_sel_op,*wxGREEN));
IL->Add(sel);
IL->Add(unsel);
IL->Add(nosel);
IL->Add(noselunsel);
IL->Add(sel_op);
IL->Add(unsel_op);
IL->Add(nosel_op);
IL->Add(noselunsel_op);
IL->Add(dr_sel);
IL->Add(dr_unsel);
IL->Add(dr_sel_op);
IL->Add(dr_unsel_op);
navigation_panel->AssignImageList(IL);
//the second spliter, the gl canvas on the left the control panel on the right
split2 = new wxSplitterWindow(split1,-1,wxPoint(0,0),wxDefaultSize,wxSP_LIVE_UPDATE);
split2->SetSashSize(3);
split2->SetMinimumPaneSize(30);
//the glcanvas
int attriblist[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 24, WX_GL_LEVEL, 0, 0 };
glcanvas = new wxGL_PMFCanvas(split2, this, PCS2_CTRL_GLCAN,wxPoint(0,0), wxSize(10,10), model, attriblist);
//the control panel
control_pane = new wxPanel(split2);
//sizer for the buttons on top of the control panel
wxBoxSizer*button_sizer = new wxBoxSizer(wxHORIZONTAL);
//the buttons themselves
button_sizer->Add(load_chunk_btn = new wxButton(control_pane, MAIN_PANEL_LOAD_CHUNK_BTN, _("Load")),1.0);
//button_sizer->Add(save_chunk_btn = new wxButton(control_pane, MAIN_PANEL_SAVE_CHUNK_BTN, _("Save")),1.0);
button_sizer->Add(transform_chunk_btn = new wxButton(control_pane, MAIN_PANEL_TRANSFORM_CHUNK_BTN, _("Transform")),1.0);
//sizer that holds the buttons and the actual control panel
control_sizer = new wxBoxSizer(wxVERTICAL);
control_sizer->Add(button_sizer,0,wxEXPAND);
control_panel = NULL;
control_sizer->Add(control_panel = new model_editor_ctrl<vector3d, ACEN_ctrl> (control_pane, model, ACEN),1.0,wxEXPAND);
glcanvas->set_active_chunk(ACEN);
// control_sizer->Add(control_panel = new model_editor_ctrl<header_data, header_ctrl> (control_pane, model, HDR2),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<vector3d, ACEN_ctrl> (control_pane, model, ACEN),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<std::string>, TXTR_ctrl> (control_pane, model, TXTR),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_slot>, WPNT_ctrl<GUN> > (control_pane, model, GPNT),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_dock_point>, DOCK_ctrl> (control_pane, model, DOCK),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_special>, SPCL_ctrl> (control_pane, model, SPCL),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_eye_pos>, EYE_ctrl> (control_pane, model, EYE),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_thruster>, FUEL_ctrl> (control_pane, model, FUEL),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_turret>, TGUN_ctrl> (control_pane, model, TGUN),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_glow_array>, GLOW_ctrl> (control_pane, model, GLOW),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<std::vector<pcs_path>, PATH_ctrl> (control_pane, model, PATH),1.0,wxEXPAND);
// control_sizer->Add(control_panel = new model_editor_ctrl<pcs_sobj, SOBJ_ctrl> (control_pane, model, SOBJ, -1),1.0,wxEXPAND);
control_panel->EnableScrolling(false,true);
control_panel->FitInside();
control_panel->SetScrollRate(0,10);
control_pane->SetSizer(control_sizer);
// control_panel->SetBackgroundColour(*wxRED);
split2->SplitVertically(glcanvas, control_pane,-30);
split2->SetSashGravity(1.0f);
split1->SetMinimumPaneSize(30);
split1->SplitVertically(navigation_panel, split2,30);
split1->SetSashGravity(0.0f);
// wxSize S = split1->GetWindow1()->GetMinSize();
//make sure this sizer takes up the whole panel
sizer->Add(split1,1.0f,wxEXPAND);
SetSizer(sizer);
sizer->Layout();
split2->SetSashPosition(-200);
split1->SetSashPosition(150);
//setup the tree
tree_id.ROOT_ID = navigation_panel->AddRoot(_("model"));
std::vector<int> path;
tree_id.HDR2_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Header"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(HDR2, path));
navigation_panel->SetItemImage(tree_id.HDR2_ID, TREE_NOSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.HDR2_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
path.resize(1);
path[0] = -1;
tree_id.SOBJ_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("SubObjects"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(SOBJ, path));
navigation_panel->SetItemImage(tree_id.SOBJ_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.SOBJ_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
path.resize(2);
path[1] = -1;
tree_id.TXTR_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Textures"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(TXTR, path));
tree_id.WEAP_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Weapon Points"), TREE_NOUNSEL, TREE_NOSEL);
tree_id.GPNT_ID = navigation_panel->AppendItem(tree_id.WEAP_ID,_("Gun Points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(GPNT, path));
tree_id.MPNT_ID = navigation_panel->AppendItem(tree_id.WEAP_ID,_("Missle Points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(MPNT, path));
tree_id.DOCK_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Docking points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(DOCK, path));
tree_id.FUEL_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Thrusters"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(FUEL, path));
tree_id.GLOW_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Glow Points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(GLOW, path));
tree_id.SPCL_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Special Points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(SPCL, path));
tree_id.TGUN_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Turrets"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(TGUN, path));
tree_id.PATH_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Paths"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(PATH, path));
tree_id.EYE_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Eye Points"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(EYE, path));
tree_id.INSG_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Insignia"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(INSG, path));
path.resize(0);
tree_id.SHLD_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Shield"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(SHLD, path));
tree_id.ACEN_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Auto-centering"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(ACEN, path));
tree_id.PINF_ID = navigation_panel->AppendItem(navigation_panel->GetRootItem(),_("Model Comments"), TREE_NOUNSEL, TREE_NOSEL, new tree_node_id(PINF, path));
navigation_panel->SetItemImage(tree_id.TXTR_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.TXTR_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.WEAP_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.WEAP_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.GPNT_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.GPNT_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.MPNT_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.MPNT_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.DOCK_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.DOCK_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.FUEL_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.FUEL_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.GLOW_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.GLOW_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.SPCL_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.SPCL_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.TGUN_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.TGUN_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.PATH_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.PATH_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.EYE_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.EYE_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.INSG_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.INSG_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.SHLD_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.SHLD_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.ACEN_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.ACEN_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.PINF_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.PINF_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
navigation_panel->SetItemImage(tree_id.SHLD_ID, TREE_NOUNSEL_OP, wxTreeItemIcon_Expanded);
navigation_panel->SetItemImage(tree_id.SHLD_ID, TREE_NOSEL_OP, wxTreeItemIcon_SelectedExpanded);
drwTimer = new wxTimer(this, PCS2_TIMER_GLDRAW);
drwTimer->Start(33);
}
DEFINE_EVENT_TYPE(wxEVT_REBUILD_TREE)
BEGIN_EVENT_TABLE(main_panel, wxPanel)
EVT_wxAsyncProgressStartEvt(OPEN_FILE_PROGRESS_MESSAGER, main_panel::open_progbar_start)
EVT_wxAsyncProgressUpdateEvt(OPEN_FILE_PROGRESS_MESSAGER, main_panel::open_progbar_update)
EVT_wxAsyncProgressEndEvt(OPEN_FILE_PROGRESS_MESSAGER, main_panel::open_progbar_end)
EVT_wxAsyncProgressStartEvt(LOAD_TEXTURE_PROGRESS_MESSAGER, main_panel::texture_progbar_start)
EVT_wxAsyncProgressUpdateEvt(LOAD_TEXTURE_PROGRESS_MESSAGER, main_panel::texture_progbar_update)
EVT_wxAsyncProgressEndEvt(LOAD_TEXTURE_PROGRESS_MESSAGER, main_panel::texture_progbar_end)
EVT_wxAsyncProgressStartEvt(OPEN_IMPORT_PROGRESS_MESSAGER, main_panel::import_progbar_start)
EVT_wxAsyncProgressUpdateEvt(OPEN_IMPORT_PROGRESS_MESSAGER, main_panel::import_progbar_update)
EVT_wxAsyncProgressEndEvt(OPEN_IMPORT_PROGRESS_MESSAGER, main_panel::import_progbar_end)
EVT_BUTTON(MAIN_PANEL_LOAD_CHUNK_BTN,main_panel::on_load_chunk)
EVT_BUTTON(MAIN_PANEL_SAVE_CHUNK_BTN,main_panel::on_save_chunk)
EVT_BUTTON(MAIN_PANEL_TRANSFORM_CHUNK_BTN,main_panel::on_transform_chunk)
EVT_BUTTON(SOBJ_BUTTON_CPY,main_panel::on_cpy_sobj)
EVT_BUTTON(SOBJ_BUTTON_DEL,main_panel::on_del_sobj)
EVT_SIZE(main_panel::OnSize)
EVT_PAINT(main_panel::OnPaint)
EVT_TREE_BEGIN_DRAG(wxID_ANY, main_panel::tree_begin_drag)
EVT_TREE_BEGIN_RDRAG(wxID_ANY, main_panel::tree_begin_drag)
EVT_TREE_END_DRAG(wxID_ANY, main_panel::tree_end_drag)
EVT_TREE_SEL_CHANGED(wxID_ANY,main_panel::on_tree_selection)
EVT_COMMAND (wxID_ANY, wxEVT_REBUILD_TREE, main_panel::on_rebuild_tree)
EVT_COMMAND(wxID_ANY, ARRAY_NEW, main_panel::on_update_tree)
EVT_COMMAND(wxID_ANY, ARRAY_CPY, main_panel::on_update_tree)
EVT_COMMAND(wxID_ANY, ARRAY_DEL, main_panel::on_update_tree)
EVT_COMMAND(wxID_ANY, EDIT_DONE, main_panel::on_update_data)
EVT_COMMAND(wxID_ANY, DATA_SELECTION_CHANGED, main_panel::on_data_selection_change)
EVT_COMMAND(wxID_ANY, BSP_RENDER_CHANGE, main_panel::on_BSP_render_change)
EVT_TEXT(wxID_ANY, main_panel::on_data_selection_change)
EVT_COMMAND(wxID_ANY, OMNIPOINT_RAY_PICKED, main_panel::on_omnipoint_ray_picked)
EVT_COMMAND(wxID_ANY, SUBOBJECT_UPDATE, main_panel::on_update_subobject)
EVT_BUTTON(TXTR_RELOAD,main_panel::on_texture_reload)
EVT_BUTTON(TXTR_EXT_OPEN,main_panel::on_texture_external_open)
EVT_BUTTON(MOI_CALC_btn,main_panel::on_moi_recalc)
END_EVENT_TABLE()
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//copy all decendents of subobject number copied_sobj
//to model with parent_new being copied_sobj's place in model
void copy_child_subobjects(PCS_Model&model, int parent_new, int copied_sobj){
for(int i = 0; i<model.GetSOBJCount(); i++){
if(model.SOBJ(i).parent_sobj == copied_sobj){
int this_obj = model.GetSOBJCount();
model.AddSOBJ(&model.SOBJ(i));
model.SOBJ(this_obj).parent_sobj = parent_new;
//set the copied object's parent to the new position
copy_child_subobjects(model, this_obj, i);
}
}
}
void main_panel::on_cpy_sobj(wxCommandEvent &event){
bool child_copy = false;
for( int i = 0; i<model.GetSOBJCount(); i++){
if(model.SOBJ(i).parent_sobj == model.get_active_model()){
if(wxMessageBox(_("This subobject has children, would you like to copy them as well?"), _("Subobject Copy"), wxYES_NO) == wxYES)
child_copy = true;
break;
}
}
std::vector<int> path;
path.resize(1);
//the number we started out with
//will be the index of the (first) new subobject
int new_obj = path[0] = model.GetSOBJCount();
model.AddSOBJ(&model.SOBJ(model.get_active_model()));
if(child_copy){
copy_child_subobjects(model, new_obj, model.get_active_model());
}
//turret
if(wxString(model.SOBJ(model.get_active_model()).properties.c_str(), wxConvUTF8).Contains(_("$fov=")) &&
wxMessageBox(_("The subobject you have copied seems like it might be a turret, \nwould you like to copy the pertenent turret data if it exsists?"), _("Subobject Copy"), wxYES_NO) == wxYES)
{
//turrets first, then paths
for( int i = 0; i<model.GetTurretCount(); i++){
if(model.Turret(i).sobj_parent == model.get_active_model()){
model.AddTurret(&model.Turret(i));
pcs_turret&active_turret = model.Turret(model.GetTurretCount()-1);
if(active_turret.sobj_parent == active_turret.sobj_par_phys){
active_turret.sobj_par_phys = active_turret.sobj_parent = new_obj;
}else{
active_turret.sobj_parent = new_obj;
//I guess we just need to find the last object with that name, it isn't bulletproff but there is no other way realy
//it'll almost always by the first one we check but there could be wonky higherarchies (someone adds a radar dish as a child of a turret's base for example)
std::string name = model.SOBJ(active_turret.sobj_par_phys).name;
for(int idx = model.GetSOBJCount()-1; i>-1; i--){
if(model.SOBJ(idx).name == name){
active_turret.sobj_par_phys = idx;
break;
}
}
}
}
}
}
control_panel->set_item(path);
control_panel->set_data(model);
model.set_active_model(path[0]);
on_update_tree(event);
}
//delete all decendents of subobject number del_sobj
//returns the first (position in the array) deleted object
int delete_child_subobjects(PCS_Model&model, int del_sobj){
int ret = INT_MAX;
for(unsigned int i = 0; (int)i<model.GetSOBJCount(); i++){
if(model.SOBJ(i).parent_sobj == del_sobj){
int youngest = delete_child_subobjects(model, i);
if(youngest < (int)i){
i=-1;
if(ret > youngest)ret = youngest;
continue;
//something before us was deleted, start over, our index is no longer valid
}
if(ret > (int)i)ret = i;
model.DelSOBJ(i);
}
}
return ret;
}
void main_panel::on_del_sobj(wxCommandEvent &event){
if(model.get_active_model() < 0 || model.get_active_model() >= (int)model.get_subobjects().size())
return;//no valis subobject selected
if(wxMessageBox(wxString::Format(_("Are your *REALLY SURE* you want to delete the object %s?\nbecause it will be gone if you do."), model.SOBJ(model.get_active_model()).name.c_str()), _("Subobject Delete"), wxYES_NO) == wxNO)
return;
bool child_delete = false;
std::vector<int> path;
path.resize(1);
path[0] = model.SOBJ(model.get_active_model()).parent_sobj;
for( int i = 0; i<model.GetSOBJCount(); i++){
if(model.SOBJ(i).parent_sobj == model.get_active_model()){
if(wxMessageBox(_("This subobject has children, would you like to kill them as well?"), _("Subobject Delete"), wxYES_NO) == wxYES)
child_delete = true;
break;
}
}
if(child_delete){
delete_child_subobjects(model, model.get_active_model());
}
//turret
if(wxString(model.SOBJ(model.get_active_model()).properties.c_str(), wxConvUTF8).Contains(_("$fov=")) &&
wxMessageBox(_("The subobject you have deleted seems like it might be a turret, \nwould you like to delete the pertenent turret data if it exsists?"), _("Subobject Delete"), wxYES_NO) == wxYES)
{
for( int i = 0; i<model.GetTurretCount(); i++){
if(model.Turret(i).sobj_parent == model.get_active_model()){
model.DelTurret(i);
}
}
}
model.DelSOBJ(model.get_active_model());
path[0] = model.get_active_model();
control_panel->set_item(path);
control_panel->set_data(model);
on_update_tree(event);
}
void remap_texture_ids(pcs_sobj& sobj, std::vector<std::string>& textures, const std::vector<std::string>& other_textures, std::map<std::string, int>& texture_map, std::vector<int>& texture_id_map) {
for (std::vector<pcs_polygon>::iterator it = sobj.polygons.begin(); it < sobj.polygons.end(); ++it) {
if (it->texture_id != -1) {
if (texture_id_map[it->texture_id] == -1) {
if (texture_map.find(other_textures[it->texture_id]) == texture_map.end()) {
texture_map[other_textures[it->texture_id]] = textures.size();
textures.push_back(other_textures[it->texture_id]);
}
texture_id_map[it->texture_id] = texture_map[other_textures[it->texture_id]];
}
it->texture_id = texture_id_map[it->texture_id];
}
}
}
void copy_subobjects(PCS_Model& destination, PCS_Model& source, int sobj, int parent, bool children, bool turret, bool path, std::vector<std::string>& textures, const std::vector<std::string>& other_textures, std::map<std::string, int>& texture_map, std::vector<int>& texture_id_map) {
remap_texture_ids(source.SOBJ(sobj), textures, other_textures, texture_map, texture_id_map);
int dest_id = destination.GetSOBJCount();
destination.AddSOBJ(&source.SOBJ(sobj));
destination.SOBJ(dest_id).parent_sobj = parent;
if (path) {
for(int i = 0; i<source.GetPathCount(); i++){
if(wxString(source.Path(i).parent.c_str(), wxConvUTF8).Contains(wxString(source.SOBJ(sobj).name.c_str(), wxConvUTF8))){
destination.AddPath(&source.Path(i));
}
}
}
std::map<int, int> old_children_to_new;
if (children) {
for (int i = 0; i < source.GetSOBJCount(); i++) {
if (source.SOBJ(i).parent_sobj == sobj) {
old_children_to_new[i] = destination.GetSOBJCount();
copy_subobjects(destination, source, i, dest_id, children, turret, path, textures, other_textures, texture_map, texture_id_map);
}
}
}
if (turret) {
for(int i = 0; i<source.GetTurretCount(); i++){
if(source.Turret(i).sobj_parent == sobj){
int dest_turret_id = destination.GetTurretCount();;
destination.AddTurret(&source.Turret(i));
destination.Turret(dest_turret_id).sobj_parent = dest_id;
// Try guessing the right barrels subobject id to use.
if (source.Turret(i).sobj_par_phys != source.Turret(i).sobj_parent && old_children_to_new.find(source.Turret(i).sobj_par_phys) != old_children_to_new.end()) {
destination.Turret(dest_turret_id).sobj_par_phys = old_children_to_new[source.Turret(i).sobj_par_phys];
} else {
destination.Turret(dest_turret_id).sobj_par_phys = dest_id;
}
}
}
}
}
void main_panel::on_transform_chunk(wxCommandEvent &event){
transform_dialog dialog(NULL, control_panel);
if (dialog.ShowModal() == wxID_OK) {
control_panel->transform(dialog.get_transform(), dialog.get_translation());
}
}
void main_panel::on_load_chunk(wxCommandEvent &event){
wxFileDialog fdlg(NULL, _("Select Import File"), _(""), _(""), PCS2_SUPPORTED_FORMATS, wxOPEN | wxFILE_MUST_EXIST);
if (fdlg.ShowModal() != wxID_OK)
return;
PCS_Model import_model;
if(!LoadImportModel(std::string(fdlg.GetPath().mb_str()), &import_model))
return;
if(control_panel->chunk_type == SOBJ){
//import of subobjects adds new subobjects rather than replaces exsisting ones
int i;
//figure out which subobjects the user wants
//get all the available subobjects
wxArrayString sobj_names;
sobj_names.Add(_("Metadata"));
sobj_names.Add(_("All Subobjects"));
for( i = 0; i<import_model.GetSOBJCount(); i++){
sobj_names.Add(wxString(import_model.SOBJ(i).name.c_str(), wxConvUTF8));
}
int imported_sobj = wxGetSingleChoiceIndex( _("Select Subobject for Importation"), _("Subobject Import"), sobj_names, this);
//user canceled
if(imported_sobj <0)
return;
if (imported_sobj == 0) {
import_sobj_metadata(import_model);
} else {
imported_sobj--;
std::vector<int> path;
path.resize(1);
//the number we started out with
//will be the index of the (first) new subobject
path[0] = model.GetSOBJCount();
glcanvas->FreezeRender = true;
std::map<std::string, int> texture_map;
std::vector<std::string> textures = model.get_textures();
std::vector<std::string> other_textures = import_model.get_textures();
std::vector<int> texture_id_map(other_textures.size(), -1);
for (std::vector<std::string>::iterator it = textures.begin(); it < textures.end(); ++it) {
texture_map[*it] = (int)(it - textures.begin());
}
bool turret_import = false;
bool path_import = false;
//turret/path import
if(wxMessageBox(_("Import associated turrets?"), _("Subobject Import"), wxYES_NO) == wxYES)
{
turret_import = true;
}
//path import
if(wxMessageBox(_("Import associated paths?"), _("Subobject Import"), wxYES_NO) == wxYES)
{
path_import = true;
}
if(imported_sobj){
imported_sobj--;
bool child_import = false;
for( i = 0; i<import_model.GetSOBJCount(); i++){
if(import_model.SOBJ(i).parent_sobj == imported_sobj){
if(wxMessageBox(_("This subobject has children, would you like to import them as well?"), _("Subobject Import"), wxYES_NO) == wxYES)
child_import = true;
break;
}
}
copy_subobjects(model, import_model, imported_sobj, -1, child_import, turret_import, path_import, textures, other_textures, texture_map, texture_id_map);
}else{
for( i = 0; i<import_model.GetSOBJCount(); i++){
if (import_model.SOBJ(i).parent_sobj == -1) {
copy_subobjects(model, import_model, i, -1, turret_import, path_import, true, textures, other_textures, texture_map, texture_id_map);
}
}
}
model.set_textures(textures);
glcanvas->reload_textures();
glcanvas->FreezeRender = false;
control_panel->set_item(path);
control_panel->set_data(model);
}
} else if (control_panel->chunk_type == TGUN) {
import_turrets(import_model);
control_panel->set_data(model);
}else{
control_panel->set_data(import_model);
//set the data in the control to the data in the import model
control_panel->apply_data(model);
//apply the data in the control (which was from the import model) to our model
}
on_update_tree(event);
}
void main_panel::import_sobj_metadata(PCS_Model& import_model) {
typedef std::map<std::string, int> NameIdMap;
NameIdMap local_map;
for (int i = 0; i < model.GetSOBJCount(); i++) {
local_map[model.SOBJ(i).name] = i;
}
for (int i = 0; i < import_model.GetSOBJCount(); i++) {
pcs_sobj& sobj = import_model.SOBJ(i);
NameIdMap::iterator it = local_map.find(sobj.name);
if (it != local_map.end()) {
pcs_sobj& local_sobj = model.SOBJ(it->second);
local_sobj.properties = sobj.properties;
local_sobj.movement_type = sobj.movement_type;
local_sobj.movement_axis = sobj.movement_axis;
}
}
}
void main_panel::import_turrets(PCS_Model& import_model) {
typedef std::map<std::string, int> NameIdMap;
NameIdMap local_map;
for (int i = 0; i < model.GetSOBJCount(); i++) {
local_map[model.SOBJ(i).name] = i;
}
std::vector<pcs_turret> turrets;
for (int i = 0; i < import_model.GetTurretCount(); i++) {
pcs_turret& import_turret = import_model.Turret(i);
if (import_turret.sobj_parent > 0 &&
import_turret.sobj_parent < import_model.GetSOBJCount() &&
import_turret.sobj_par_phys > 0 &&
import_turret.sobj_par_phys < import_model.GetSOBJCount()) {
int local_parent = -1;
int local_phys_parent = -1;
NameIdMap::iterator jt;
if ((jt = local_map.find(import_model.SOBJ(import_turret.sobj_parent).name)) !=
local_map.end()) {
local_parent = jt->second;
}
if ((jt =
local_map.find(import_model.SOBJ(import_turret.sobj_par_phys).name)) !=
local_map.end()) {
local_phys_parent = jt->second;
}
if (local_phys_parent != -1 && local_parent != -1) {
pcs_turret turret(import_turret);
turret.sobj_parent = local_parent;
turret.sobj_par_phys = local_phys_parent;
turrets.push_back(turret);
}
}
}
model.set_turrets(turrets);
}
void main_panel::on_save_chunk(wxCommandEvent &event){
// control_panel->save_chunk();
}
void main_panel::on_BSP_render_change(wxCommandEvent &event){
model.draw_bsp = event.GetInt()!=0;
glcanvas->Render(); // force update (render) on change
}
void main_panel::OnSize(wxSizeEvent& event)
{
if (isDestroyed) return; // for some reason we're crashing without this - Kaz
int x = event.GetSize().GetWidth();
// size the statusbar fields
int widths[3];
// 10%, 95%, 5%
widths[0] = int(float(x)*0.15f);
widths[1] = int(float(x)*0.70f);
widths[2] = int(float(x)*0.15f);
pstatus->SetFieldsCount(3, widths);
pgauge->SetSize(widths[0]+5, 3, widths[1]-2, pstatus->GetSize().GetHeight()-3);
event.Skip();
}
//shamelessly stolen from kaz's main panel
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool main_panel::Destroy()
{
isDestroyed=true;
model.Reset();
glcanvas->FreezeRender = true;
while (glcanvas->IsRendering);
glcanvas->Destroy();
//dtree->Destroy();
return true;
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool main_panel::LoadImportModel(std::string filename, PCS_Model*import_model)
{
AsyncProgress* prog_messenger(new wxAsyncProgress(this, OPEN_IMPORT_PROGRESS_MESSAGER));
wxPCS2OpenThread *thread = new wxPCS2OpenThread(import_model, filename, prog_messenger, false);
thread->Create();
thread->Run();
// unfortunately for this one we have to block - all the calling functions expect this function to block
while (!prog_messenger->Finished())
{
wxMicroSleep(250);
wxSafeYield(this->GetParent(),true);
}
bool result = !prog_messenger->EarlyTerminated();
delete prog_messenger;
return result;
/*
bool *IsRunning = new bool; *IsRunning = true;
int *comp_target = new int; *comp_target = 0;
int *comp_current = new int; *comp_current = 0;
int *error_code = new int; *error_code = 0;
char *comp_msg = new char[128];
memset(comp_msg, 0, 128);
int retval;
int last_cur = 0;
int comp;
wxString msg = "Starting Load";
wxProgressDialog *prog = new wxProgressDialog("Opening File", msg);
import_model->Reset();
wxPCS2OpenThread *thread = new wxPCS2OpenThread(this, import_model, comp_target, comp_current, IsRunning, error_code, filename, comp_msg);
thread->Create();
thread->Run();
while (*IsRunning)
{
if (comp_target != 0)
{
if (last_cur != *comp_current)
{
last_cur = *comp_current;
msg = comp_msg;
comp = int((float(*comp_current)/float(*comp_target)*100.0));
if (comp > 100)
comp = 100;
prog->Update(comp, msg);
}
}
wxMicroSleep(250);
wxSafeYield(this->GetParent(),true);
}
delete prog;
retval = *error_code;
delete IsRunning;
delete comp_target;
delete comp_current;
delete error_code;
delete[] comp_msg;
return retval==0;*/
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
void main_panel::global_import(std::string filename){
PCS_Model import_model;
if(!LoadImportModel(filename, &import_model))
return;
model.set_ai_paths(import_model.get_ai_paths());
model.set_docking(import_model.get_docking());
model.set_eyes(import_model.get_eyes());
model.set_glow_points(import_model.get_glow_points());
model.set_insignia(import_model.get_insignia());
model.set_shield_mesh(import_model.get_shield_mesh());
model.set_special(import_model.get_special());
model.set_thrusters(import_model.get_thrusters());
model.set_weapons(import_model.get_weapons());
import_turrets(import_model);
import_sobj_metadata(import_model);
wxCommandEvent event;
on_update_tree(event);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
void main_panel::ImportGeometry(std::string filename)
{
PCS_Model import_model;
if(!LoadImportModel(filename, &import_model))
return;
// merge texture list
std::vector<std::string> txts = model.get_textures();
for (int i = 0; i < import_model.GetTexturesCount(); i++)
{
if (!in_array<std::string>(txts, import_model.Texture(i)))