-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathM3 Import Macro.ms
1992 lines (1843 loc) · 70.5 KB
/
M3 Import Macro.ms
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
---------------------------------------------------------------------------
global M3G_ImportInfo_Glb
struct M3S_INIdata
(
sectionStr, keyStr, value
)
fn M3F_FormatToString str_FP items_FP =
(
local ret_string = ""
local split_strings = filterString str_FP "%" splitEmptyTokens:true
for i=1 to (split_strings.count-1) do
(
ret_string = ret_string + split_strings[i] + (items_FP[i] as string)
)
ret_string = ret_string + split_strings[split_strings.count]
)
fn M3F_AccessINI ini_FP part_FP type_FP =
(
local ini_path = case ini_FP of
(
#setting: "$plugcfg\\M3_Import_Settings.ini"
#language: "$temp\\M3Import_mzp\\M3_Import_Languages.ini"
default: "$plugcfg\\M3_Import_Settings.ini"
)
case type_FP of
(
#save:
(setINISetting ini_path part_FP.sectionStr part_FP.keyStr (part_FP.value as string))
#load:
(
local get_val = getINISetting ini_path part_FP.sectionStr part_FP.keyStr
if(get_val.count > 0)then
(
local origin_class = classOf part_FP.value
local new_value = if(origin_class == string)then(get_val)else(try(execute get_val)catch(undefined))
if(new_value != undefined)then(try(part_FP.value = new_value as origin_class)catch())
)
)
)
part_FP.value
)
fn M3F_ReadLanguage language_FP item_FP default_FP =
(
local string_read = M3F_AccessINI #language (M3S_INIdata language_FP item_FP default_FP) #load
)
fn M3F_CheckStarTools type_FP func: =
(
case type_FP of
(
#Init:
(
try
(
local props = getPropNames starTools
if(props != #(#Behaviors, #INI, #AssetsTracking, \
#helpers, #menu, #AnimProps, #Utilities, \
#info, #log, #export, #DisplaySettings))then
(
undefined = 1
)
)catch
(messageBox "CAN'T FOUND STAR ART TOOLS!!!"; return false)
)
#Info:(try(starTools.Info)catch(messageBox "CAN'T FOUND STAR ART TOOLS!!!"; return false))
)
case func of
(
#gameDir:
(
local game_dir = StarTools.Info.GetDir #localBuild
if(game_dir == undefined)then(game_dir = "")
if((doesFileExist (game_dir + "\\StarCraft II.exe")) != true)then
(
messageBox ("Wrong SC2 game path !!!\n" + \
"Please select the game path first!!!\n" + \
"Please select the folder containing the StarCraft II exe.")
StarTools.Info.SetLocalBuildPath()
game_dir = StarTools.Info.GetDir #localBuild
if(game_dir == undefined)then(game_dir = "")
if((doesFileExist (game_dir + "\\StarCraft II.exe")) != true)then
(
messageBox "Bad configuration. Operation cancelled."
return false
)
)
)
)
true
)
struct M3S_ImportInfo
(
verison = "v1.8",
ExtractFileLib,
--Misc
Language = M3S_INIdata "Misc" "Language" "English",
btnItem = \
#(
#("647394", "M3M_FileImport`CaptainD", "M3 file import tool.", "M3-Import"),
#("647394", "M3M_TexMapFix`CaptainD", "Fix textures path problem.", "M3-TexMapFix")
),
--Import Tool
MainUI, dialogCheck = false, progressLv = 20.0, currProgLv = 0.0,
missingMap = #(), lastFileName = "None", lastPath = "", DetailsUI, cancelCheck = false,
posUI = M3S_INIdata "Import" "posUI" [500, 100],
heightUI = M3S_INIdata "Import" "heightUI" 880,
showDetails = M3S_INIdata "Import" "showDetails" true,
missingCheck = M3S_INIdata "Import" "missingCheck" true,
mapPath = M3S_INIdata "Import" "mapPath" "",
pathSelect = M3S_INIdata "Import" "pathSelect" 2,
impTrack = M3S_INIdata "Import" "impTrack" true,
impSeq = M3S_INIdata "Import" "impSeq" true,
impAnim = M3S_INIdata "Import" "impAnim" true,
impEvt = M3S_INIdata "Import" "impEvt" true,
impTurt = M3S_INIdata "Import" "impTurt" true,
impBBrd = M3S_INIdata "Import" "impBBrd" true,
impIK = M3S_INIdata "Import" "impIK" true,
impMat = M3S_INIdata "Import" "impMat" true,
impBone = M3S_INIdata "Import" "impBone" true,
impMesh = M3S_INIdata "Import" "impMesh" true,
impSkin = M3S_INIdata "Import" "impSkin" true,
impHit = M3S_INIdata "Import" "impHit" true,
impVol = M3S_INIdata "Import" "impVol" true,
impAttach = M3S_INIdata "Import" "impAttach" true,
impBound = M3S_INIdata "Import" "impBound" true,
impLight = M3S_INIdata "Import" "impLight" true,
impCam = M3S_INIdata "Import" "impCam" true,
impPart = M3S_INIdata "Import" "impPart" true,
impPhy = M3S_INIdata "Import" "impPhy" true,
setGPos = M3S_INIdata "Global Settings" "setGPos" [0,0,0],
setGScale = M3S_INIdata "Global Settings" "setGScale" 1.0,
setFRate = M3S_INIdata "Animation Settings" "setFRate" 30,
setFBSeq = M3S_INIdata "Animation Settings" "setFBSeq" 40,
setFCorrect = M3S_INIdata "Animation Settings" "setFCorrect" 30.0,
setFCheckR = M3S_INIdata "Animation Settings" "setFCheckR" 1,
setWeldSmooth = M3S_INIdata "Mesh Settings" "setWeldSmooth" 1,
setSmoothType = M3S_INIdata "Mesh Settings" "setSmoothType" 2,
setSmoothAngle = M3S_INIdata "Mesh Settings" "setSmoothAngle" 45.0,
setBEntity = M3S_INIdata "Bone Settings" "setBEntity" 1,
setBSize1 = M3S_INIdata "Bone Settings" "setBSize1" 2.0,
setBSize2 = M3S_INIdata "Bone Settings" "setBSize2" 5.0,
setBSize3 = M3S_INIdata "Bone Settings" "setBSize3" 1.0,
setBAnim = M3S_INIdata "Bone Settings" "setBAnim" true,
setBLink = M3S_INIdata "Bone Settings" "setBLink" false,
setBFix = M3S_INIdata "Bone Settings" "setBFix" false,
setBPosCtl = M3S_INIdata "Bone Settings" "setBPosCtl" 1,
setBRotCtl = M3S_INIdata "Bone Settings" "setBRotCtl" 1,
setBScaleCtl = M3S_INIdata "Bone Settings" "setBScaleCtl" 2,
setAttSize = M3S_INIdata "Helper Settings" "setAttSize" 5,
setAttScale = M3S_INIdata "Helper Settings" "setAttScale" false,
setBoundColl = M3S_INIdata "Helper Settings" "setBoundColl" true,
setAttColl = M3S_INIdata "Helper Settings" "setAttColl" false,
setVolColl = M3S_INIdata "Helper Settings" "setVolColl" true,
setHitColl = M3S_INIdata "Helper Settings" "setHitColl" true,
setLTrans = M3S_INIdata "Light Settings" "setLTrans" true,
setLPar = M3S_INIdata "Light Settings" "setLPar" true,
setCTrans = M3S_INIdata "Camera Settings" "setCTrans" true,
setCPar = M3S_INIdata "Camera Settings" "setCPar" true,
setPTrans = M3S_INIdata "Particle Settings" "setPTrans" true,
setPPar = M3S_INIdata "Particle Settings" "setPPar" true,
--Textures tool
texToolUI, texDialogCheck = false,
fn getToolsBarItems idx_FP =
(
local item_str = "2|0|0|31|3|" + this.btnItem[idx_FP][1] + "|" + this.btnItem[idx_FP][2] + \
"|0|0|\"" + this.btnItem[idx_FP][3] + "\"|\"" + this.btnItem[idx_FP][4] + "\"|-1|"
),
fn checkToolBarExist =
(
local cuiFile = cui.getConfigFile()
local changed = false
if(toLower (getFilenameType cuiFile) == ".cui")then
(
if (hasINISetting cuiFile #CUIData #WindowCount) and (hasINISetting cuiFile #CUIWindows)do
(
local itemsCount = (getINISetting cuiFile #CUIData #WindowCount) as integer
local allWindows = for n in 1 to itemsCount collect
(
local pad_num = "000"+((n - 1)as string)
local curItem = "F" + (substring pad_num (pad_num.count-2) -1)
local curWindow = getINISetting cuiFile #CUIWindows curItem
(filterstring curWindow ":")[2]
)
if (FindItem allWindows "CaptainD") == 0 do
(
local pad_num1 = "000"+(itemsCount as string)
local newItem = "F" + (substring pad_num1 (pad_num1.count-2) -1)
setINISetting cuiFile #CUIData #WindowCount ((itemsCount + 1) as string)
setINISetting cuiFile #CUIWindows newItem "T:CaptainD"
changed = true
)
)
if not (hasINISetting cuiFile #CaptainD) do
(
setINISetting cuiFile #CaptainD #Rank "0"
setINISetting cuiFile #CaptainD #SubRank "2"
setINISetting cuiFile #CaptainD #Hidden "0"
setINISetting cuiFile #CaptainD #DPanel "1"
setINISetting cuiFile #CaptainD #Tabbed "0"
setINISetting cuiFile #CaptainD #TabCt "0"
setINISetting cuiFile #CaptainD #CurTab "-1"
setINISetting cuiFile #CaptainD #CType "1"
setINISetting cuiFile #CaptainD #ToolbarRows "1"
setINISetting cuiFile #CaptainD #ToolbarType "3"
setINISetting cuiFile #CaptainD #CurPos "1 278 349 358 418"
setINISetting cuiFile #CaptainD #ItemCount (this.btnItem.count as string)
for i=1 to this.btnItem.count do
(
setINISetting cuiFile #CaptainD ("item"+((i-1) as string)) (getToolsBarItems i)
)
changed = true
)
if(changed)then
(
cui.loadConfig cuiFile
cui.saveConfig()
)
)else
(
if(doesFileExist cuiFile)then
(
local XmlDoc = dotNetObject "system.xml.xmlDocument"
XmlDoc.load cuiFile
local docElement = try(XmlDoc.documentElement) catch(undefined)
if docElement != undefined then
(
local CUIWindowsElement = docElement.SelectSingleNode "//ADSK_CUI//CUIWindows"
if CUIWindowsElement != undefined then
(
local toolbarElement = docElement.SelectSingleNode \
"//ADSK_CUI//CUIWindows//Window[@name='CaptainD']"
if toolbarElement == undefined do
(
local posAttributeNames = #("FRect", "DRect", "DRectPref", "CurPos")
local posAttributeValues = \
#(
#("698", "542", "764", "611"),
#("1235", "53", "1280", "92"),
#("2147483647", "2147483647","-2147483648", "-2147483648"),
#("1235", "53", "1280", "92", "0", "1")
)
toolbarElement = XmlDoc.CreateElement "Window"
toolbarElement.SetAttribute "name" "CaptainD"
toolbarElement.SetAttribute "type" "T"
toolbarElement.SetAttribute "rank" "0"
toolbarElement.SetAttribute "subRank" "2"
toolbarElement.SetAttribute "hidden" "0"
toolbarElement.SetAttribute "dPanel" "1"
toolbarElement.SetAttribute "tabbed" "0"
toolbarElement.SetAttribute "curTab" "-1"
toolbarElement.SetAttribute "cType" "1"
toolbarElement.SetAttribute "toolbarRows" "1"
toolbarElement.SetAttribute "toolbarType" "3"
CUIWindowsElement.AppendChild toolbarElement
local counter = 1
for curAttributeName in posAttributeNames do
(
local newElement = XmlDoc.CreateElement curAttributeName
local curAttributeValues = posAttributeValues[counter]
newElement.SetAttribute "left" curAttributeValues[1]
newElement.SetAttribute "top" curAttributeValues[2]
newElement.SetAttribute "right" curAttributeValues[3]
newElement.SetAttribute "bottom" curAttributeValues[4]
if curAttributeValues.count > 4 do
(
newElement.SetAttribute "floating" curAttributeValues[5]
newElement.SetAttribute "panelID" curAttributeValues[6]
)
toolbarElement.AppendChild newElement
counter += 1
)
toolbarElement.AppendChild (XmlDoc.CreateElement "Items")
changed = true
)
)
local itemsElement = docElement.SelectSingleNode \
"//ADSK_CUI//CUIWindows//Window[@name='CaptainD']//Items"
if itemsElement != undefined do
(
local ToolbarItemsToAdd = #()
for i=this.btnItem.count to 1 by -1 do
(
append ToolbarItemsToAdd this.btnItem[i]
)
for curItem in ToolbarItemsToAdd do
(
local actionTableID = curItem[1]
local actionId = curItem[2]
if((docElement.SelectSingleNode \
("//ADSK_CUI//CUIWindows//Window[@name='CaptainD']//" + \
"Items/Item[@actionTableID='" + actionTableID + \
"' and @actionID='" + actionId + "']")) == undefined)do
(
local newElement = XmlDoc.CreateElement "Item"
newElement.SetAttribute "typeID" "2"
newElement.SetAttribute "type" "CTB_MACROBUTTON"
newElement.SetAttribute "width" "0"
newElement.SetAttribute "height" "0"
newElement.SetAttribute "controlID" "0"
newElement.SetAttribute "macroTypeID" "3"
newElement.SetAttribute "macroType" "MB_TYPE_ACTION"
newElement.SetAttribute "actionTableID" actionTableID
newElement.SetAttribute "imageID" "-1"
newElement.SetAttribute "imageName" ""
newElement.SetAttribute "actionID" actionId
newElement.SetAttribute "tip" curItem[3]
newElement.SetAttribute "label" curItem[4]
itemsElement.PrependChild newElement
changed = true
)
)
)
if(changed)then
(
XmlDoc.save cuiFile
cui.loadConfig cuiFile
)
)else
(
messageBox "Can't create M3 Import ToolBar Item! Please add it manually."
)
)else
(
messageBox "Can't create M3 Import ToolBar Item! Please add it manually."
)
)
),
fn removeToolBar =
(
local cuiFile = cui.getConfigFile()
--local changed = false
if(toLower (getFilenameType cuiFile) == ".cui")then
(
if (hasINISetting cuiFile #CUIData #WindowCount) and (hasINISetting cuiFile #CUIWindows)do
(
local itemsCount = (getINISetting cuiFile #CUIData #WindowCount) as integer
local allWindows = #()
for n in 1 to itemsCount do
(
local pad_num = "000"+((n - 1)as string)
local curItem = "F" + (substring pad_num (pad_num.count-2) -1)
local curWindow = getINISetting cuiFile #CUIWindows curItem
if toLower ((filterstring curWindow ":")[2]) != toLower "CaptainD" do
(
append allWindows curWindow
)
)
local allWindowsCount = allWindows.count
if itemsCount != allWindowsCount do
(
setINISetting cuiFile #CUIData #WindowCount (allWindowsCount as string)
for n in 1 to itemsCount do
(
local pad_num = "000"+((n - 1)as string)
local curItem = "F" + (substring pad_num (pad_num.count-2) -1)
if n <= allWindowsCount then
(
setINISetting cuiFile #CUIWindows curItem allWindows[n]
)
else
(
delIniSetting cuiFile #CUIWindows curItem
)
)
--changed = true
)
)
if hasINISetting cuiFile #CaptainD do(delIniSetting cuiFile #CaptainD)
--if(changed)then(cui.loadConfig cuiFile)
)else
(
if(doesFileExist cuiFile)then
(
local XmlDoc = dotNetObject "system.xml.xmlDocument"
XmlDoc.load cuiFile
local docElement = try(XmlDoc.documentElement) catch(undefined)
if(docElement != undefined)then
(
local CUIWindowsElement = docElement.SelectSingleNode "//ADSK_CUI//CUIWindows"
if CUIWindowsElement != undefined then
(
local toolbarElement = docElement.SelectSingleNode \
"//ADSK_CUI//CUIWindows//Window[@name='CaptainD']"
if toolbarElement != undefined do
(
local toolbarItemsToRemove = #()
for i=1 to this.btnItem.count do
(
append toolbarItemsToRemove this.btnItem[i]
)
local itemsElement = docElement.SelectSingleNode \
"//ADSK_CUI//CUIWindows//Window[@name='CaptainD']//Items"
if itemsElement != undefined do
(
for curItem in toolbarItemsToRemove do
(
local actionTableID = curItem[1]
local actionId = curItem[2]
local curItemToRemove = docElement.SelectSingleNode \
("//ADSK_CUI//CUIWindows//Window[@name='CaptainD']//" + \
"Items//Item[@actionTableID='" + actionTableID + \
"' and @actionID='" + actionId + "']")
if curItemToRemove != undefined do
(
itemsElement.RemoveChild curItemToRemove
)
)
if not (itemsElement.HasChildNodes) do
(
CUIWindowsElement.RemoveChild toolbarElement
)
)
--changed = true
)
)
XmlDoc.save cuiFile
--if(changed)then(cui.loadConfig cuiFile)
)
)
)
),
fn accessMiscSettings type_FP =
(
M3F_AccessINI #setting this.Language type_FP
),
fn accessImportUIsettings type_FP =
(
M3F_AccessINI #setting this.posUI type_FP
M3F_AccessINI #setting this.heightUI type_FP
M3F_AccessINI #setting this.showDetails type_FP
M3F_AccessINI #setting this.missingCheck type_FP
M3F_AccessINI #setting this.mapPath type_FP
M3F_AccessINI #setting this.pathSelect type_FP
M3F_AccessINI #setting this.impTrack type_FP
M3F_AccessINI #setting this.impSeq type_FP
M3F_AccessINI #setting this.impAnim type_FP
M3F_AccessINI #setting this.impEvt type_FP
M3F_AccessINI #setting this.impTurt type_FP
M3F_AccessINI #setting this.impBBrd type_FP
M3F_AccessINI #setting this.impIK type_FP
M3F_AccessINI #setting this.impMat type_FP
M3F_AccessINI #setting this.impBone type_FP
M3F_AccessINI #setting this.impMesh type_FP
M3F_AccessINI #setting this.impSkin type_FP
M3F_AccessINI #setting this.impHit type_FP
M3F_AccessINI #setting this.impVol type_FP
M3F_AccessINI #setting this.impAttach type_FP
M3F_AccessINI #setting this.impBound type_FP
M3F_AccessINI #setting this.impLight type_FP
M3F_AccessINI #setting this.impCam type_FP
M3F_AccessINI #setting this.impPart type_FP
M3F_AccessINI #setting this.impPhy type_FP
M3F_AccessINI #setting this.setGPos type_FP
M3F_AccessINI #setting this.setGScale type_FP
M3F_AccessINI #setting this.setFRate type_FP
M3F_AccessINI #setting this.setFBSeq type_FP
M3F_AccessINI #setting this.setFCorrect type_FP
M3F_AccessINI #setting this.setFCheckR type_FP
M3F_AccessINI #setting this.setWeldSmooth type_FP
M3F_AccessINI #setting this.setSmoothType type_FP
M3F_AccessINI #setting this.setSmoothAngle type_FP
M3F_AccessINI #setting this.setBEntity type_FP
M3F_AccessINI #setting this.setBSize1 type_FP
M3F_AccessINI #setting this.setBSize2 type_FP
M3F_AccessINI #setting this.setBSize3 type_FP
M3F_AccessINI #setting this.setBAnim type_FP
M3F_AccessINI #setting this.setBLink type_FP
M3F_AccessINI #setting this.setBFix type_FP
M3F_AccessINI #setting this.setBPosCtl type_FP
M3F_AccessINI #setting this.setBRotCtl type_FP
M3F_AccessINI #setting this.setBScaleCtl type_FP
M3F_AccessINI #setting this.setAttSize type_FP
M3F_AccessINI #setting this.setAttScale type_FP
M3F_AccessINI #setting this.setBoundColl type_FP
M3F_AccessINI #setting this.setAttColl type_FP
M3F_AccessINI #setting this.setVolColl type_FP
M3F_AccessINI #setting this.setHitColl type_FP
M3F_AccessINI #setting this.setLTrans type_FP
M3F_AccessINI #setting this.setLPar type_FP
M3F_AccessINI #setting this.setCTrans type_FP
M3F_AccessINI #setting this.setCPar type_FP
M3F_AccessINI #setting this.setPTrans type_FP
M3F_AccessINI #setting this.setPPar type_FP
),
fn defaultImportUIsettings =
(
this.showDetails.value = true
this.missingCheck.value = true
this.mapPath.value = ""
this.pathSelect.value = 2
this.impTrack.value = true
this.impSeq.value = true
this.impAnim.value = true
this.impEvt.value = true
this.impTurt.value = true
this.impBBrd.value = true
this.impIK.value = true
this.impMat.value = true
this.impBone.value = true
this.impMesh.value = true
this.impSkin.value = true
this.impHit.value = true
this.impVol.value = true
this.impAttach.value = true
this.impBound.value = true
this.impLight.value = true
this.impCam.value = true
this.impPart.value = true
this.impPhy.value = true
this.setGPos.value = [0,0,0]
this.setGScale.value = 1.0
this.setFRate.value = 30
this.setFBSeq.value = 40
this.setFCorrect.value = 30.0
this.setFCheckR.value = 1
this.setWeldSmooth.value = 1
this.setSmoothType.value = 2
this.setSmoothAngle.value = 45.0
this.setBEntity.value = 1
this.setBSize1.value = 2.0
this.setBSize2.value = 5.0
this.setBSize3.value = 1.0
this.setBAnim.value = true
this.setBLink.value = false
this.setBFix.value = false
this.setBPosCtl.value = 1
this.setBRotCtl.value = 1
this.setBScaleCtl.value = 2
this.setAttSize.value = 5
this.setAttScale.value = false
this.setBoundColl.value = true
this.setAttColl.value = false
this.setVolColl.value = true
this.setHitColl.value = true
this.setLTrans.value = true
this.setLPar.value = true
this.setCTrans.value = true
this.setCPar.value = true
this.setPTrans.value = true
this.setPPar.value = true
),
on create do
(
M3F_CheckStarTools #Init
this.accessMiscSettings #load
local assembly = dotnet.loadAssembly @"$Temp\M3Import_mzp\ExtractFile_M3Lib.dll"
this.ExtractFileLib = dotNetObject (assembly.GetExportedTypes())[1].FullName
if(heapSize < 150000000)then
(
heapSize = 150000000
)
)
)
M3G_ImportInfo_Glb = M3S_ImportInfo()
---------------------------------------------------------------------------
--include Files------------------------------------------------------------
---------------------------------------------------------------------------
include "M3 Import DotNetHelper.ms"
include "M3 Import M3DataStruct.ms"
include "M3 Import MiscUtil.ms"
---------------------------------------------------------------------------
---------------------------------------------------------------------------
M3G_ImportInfo_Glb.removeToolBar()
M3G_ImportInfo_Glb.checkToolBarExist()
callbacks.addScript #postSystemStartup "M3G_ImportInfo_Glb.checkToolBarExist()" id:#M3ImportStartUp
callbacks.addScript #preSystemShutdown "M3G_ImportInfo_Glb.removeToolBar()" id:#M3ImportShutDown
---------------------------------------------------------------------------
---------------------------------------------------------------------------
--------------------UI Code------------------------------------------------
---------------------------------------------------------------------------
---------------------------------------------------------------------------
struct M3S_DetailsForm
(
parentHwnd, mainForm, showed = false, showLogCheck = false, stepCnt = 0, warningCnt = 0, errorCnt = 0,
lastErrorLabel, progressCtl, cancelBtn, showLogBtn, warningsLabel, errorsLabel, logsList,
posUI = M3S_INIdata "DetailsForm" "posUI" [500, 100],
widthUI = M3S_INIdata "DetailsForm" "widthUI" 800,
heightUI = M3S_INIdata "DetailsForm" "heightUI" 240,
fn accessSettings type_FP =
(
M3F_AccessINI #setting this.posUI type_FP
M3F_AccessINI #setting this.widthUI type_FP
M3F_AccessINI #setting this.heightUI type_FP
),
fn cancelEnabled state_FP =
(
try(this.cancelBtn.Enabled = state_FP)catch()
),
fn updateCount =
(
try
(
this.warningsLabel.Text = "Warnings:" + (this.warningCnt as string)
this.errorsLabel.Text = "Errors:" + (this.errorCnt as string)
)catch()
),
fn setProgress val_FP =
(
local progress_value = if(val_FP > 100)then(100)else if(val_FP < 0)then(0)else(val_FP)
try(this.progressCtl.Value = progress_value)catch()
),
fn setLogInfo info_FP type: =
(
if(M3G_ImportInfo_Glb.showDetails.value != true)then
(
case type of
(
#Warning:
(
this.warningCnt += 1
try(this.lastErrorLabel.Text = info_FP)catch()
this.updateCount()
)
#Error:
(
this.errorCnt += 1
try(this.lastErrorLabel.Text = info_FP)catch()
this.updateCount()
)
#Finished:
(
try(if(this.lastErrorLabel.Text == "")then(this.lastErrorLabel.Text = info_FP))catch()
)
)
return false
)
local netClass = M3S_DotNetClass()
local add_item = netClass.createCtl #ListViewItem
if(type != unsupplied)then
(
add_item.Text = this.stepCnt as string
this.stepCnt += 1
)
case type of
(
#Info:
(
add_item.ImageIndex = 0
add_item.SubItems.Add "Info"
)
#Warning:
(
add_item.ImageIndex = 1
add_item.SubItems.Add "Warning"
this.warningCnt += 1
try(this.lastErrorLabel.Text = info_FP)catch()
)
#Error:
(
add_item.ImageIndex = 2
add_item.SubItems.Add "Error"
this.errorCnt += 1
try(this.lastErrorLabel.Text = info_FP)catch()
)
#Finished:
(
add_item.ImageIndex = 0
add_item.SubItems.Add "Info"
try(if(this.lastErrorLabel.Text == "")then(this.lastErrorLabel.Text = info_FP))catch()
)
default: add_item.SubItems.Add ""
)
add_item.SubItems.Add info_FP
this.updateCount()
try
(
this.logsList.Items.Add add_item
this.logsList.Items.Item[this.logsList.Items.Count-1].EnsureVisible()
)catch()
),
fn clearLogInfo =
(
this.stepCnt = 0
this.warningCnt = 0
this.errorCnt = 0
this.updateCount()
try
(
this.logsList.Items.Clear()
this.progressCtl.Value = 0
this.lastErrorLabel.Text = ""
)catch()
),
fn showUI =
(
if(this.showed == false)then
(
local netClass = M3S_DotNetClass()
this.accessSettings #load
if(this.mainForm.IsDisposed)then(this.createUI())
this.mainForm.Size = netClass.createObject #Size d1:this.widthUI.value d2:this.heightUI.value
this.showed = true
this.mainForm.Show this.parentHwnd
this.mainForm.Location = netClass.createObject #Point d1:this.posUI.value[1] d2:this.posUI.value[2]
)else
(
this.mainForm.topMost = true
this.mainForm.topMost = false
)
),
fn hideUI =
(
try(M3G_ImportInfo_Glb.MainUI.Import_subRoll.rollouts[1].Show_Details_Btn.state = false)catch()
this.posUI.value = [this.mainForm.Location.X, this.mainForm.Location.Y]
this.widthUI.value = this.mainForm.Width
this.heightUI.value = this.mainForm.Height
this.accessSettings #save
this.showed = false
this.mainForm.Hide()
),
fn cancelClickEvent sender_FP e_FP =
(
M3G_ImportInfo_Glb.cancelCheck = true
),
fn showLogEvent sender_FP e_FP =
(
if(sender_FP.Tag.Value.showLogCheck)then(return true)
sender_FP.Tag.Value.showLogCheck = true
local netClass = M3S_DotNetClass()
if(sender_FP.Checked == true)then
(
sender_FP.Tag.Value.mainForm.Size = \
netClass.createObject #Size d1:sender_FP.Tag.Value.mainForm.Size.Width d2:500
)else
(
sender_FP.Tag.Value.mainForm.Size = \
netClass.createObject #Size d1:sender_FP.Tag.Value.mainForm.Size.Width d2:151
)
sender_FP.Tag.Value.showLogCheck = false
),
fn sizeChangedEvent sender_FP e_FP =
(
sender_FP.Tag.Value.logsList.Columns.Item[2].Width = sender_FP.Size.Width - 152
),
fn sizeChangedEndEvent sender_FP e_FP =
(
if(sender_FP.Tag.Value.showLogCheck)then(return true)
sender_FP.Tag.Value.showLogCheck = true
if(sender_FP.Size.Height == 151)then
(
sender_FP.Tag.Value.showLogBtn.Checked = false
)else
(
sender_FP.Tag.Value.showLogBtn.Checked = true
)
sender_FP.Tag.Value.showLogCheck = false
),
fn closeUIevent sender_FP e_FP =
(
e_FP.Cancel = true
sender_FP.Tag.Value.hideUI()
),
fn columnWidthChangingEvent sender_FP e_FP =
(
e_FP.Cancel = true
e_FP.NewWidth = sender_FP.Columns.Item[e_FP.ColumnIndex].Width
),
fn createUI =
(
local netClass = M3S_DotNetClass()
local icon_path = \
#(
(symbolicPaths.expandFileName @"$Temp\M3Import_mzp\Icons\Info.png"),
(symbolicPaths.expandFileName @"$Temp\M3Import_mzp\Icons\Warning.png"),
(symbolicPaths.expandFileName @"$Temp\M3Import_mzp\Icons\Error.png")
)
local form_icon_path = symbolicPaths.expandFileName @"$Temp\M3Import_mzp\Icons\max.ico"
this.parentHwnd = netClass.createObject #Handle d1:(windows.getMAXHWND())
-----------------------------------------------------------------------------------------
this.mainForm = netClass.createCtl #Form w:800 h:240 t:"Importer Details Output"
this.mainForm.Icon = netClass.createObject #Icon d1:form_icon_path d2:16
this.mainForm.MinimumSize = netClass.createObject #Size d1:400 d2:151
this.mainForm.Font = netClass.createObject #Font
this.mainForm.ShowInTaskbar = false
this.mainForm.Tag = dotNetMXSValue this
dotnet.addeventhandler this.mainForm "Resize" sizeChangedEvent
dotnet.addeventhandler this.mainForm "ResizeEnd" sizeChangedEndEvent
dotnet.addeventhandler this.mainForm "FormClosing" closeUIevent
-----------------------------------------------------------------------------------------
this.lastErrorLabel = netClass.createCtl #Label x:10 y:6 w:700 h:16 t:""
this.mainForm.Controls.Add this.lastErrorLabel
this.progressCtl = netClass.createCtl #ProgressBar a:#Anchor v:"Left, Right, Top" x:10 y:35 w:672 h:20
this.mainForm.Controls.Add this.progressCtl
-----------------------------------------------------------------------------------------
this.cancelBtn = netClass.createCtl #Button a:#Anchor v:"Right, Top" \
x:690 y:35 w:78 h:28 t:"Cancel"
this.cancelBtn.Enabled = false
this.mainForm.Controls.Add this.cancelBtn
dotnet.addeventhandler this.cancelBtn "Click" cancelClickEvent
this.showLogBtn = netClass.createCtl #CheckBox a:#Anchor v:"Right, Top" \
x:690 y:64 w:78 h:28 t:"Show Logs" ta:#MiddleCenter
this.showLogBtn.Appearance = (netClass.getClass #Appearance).Button
this.showLogBtn.Tag = dotNetMXSValue this
this.mainForm.Controls.Add this.showLogBtn
dotnet.addeventhandler this.showLogBtn "CheckedChanged" showLogEvent
-----------------------------------------------------------------------------------------
this.warningsLabel = netClass.createCtl #Label x:10 y:64 w:100 h:16 t:"Warnings:0"
this.mainForm.Controls.Add this.warningsLabel
this.errorsLabel = netClass.createCtl #Label x:110 y:64 w:100 h:16 t:"Errors:0"
this.mainForm.Controls.Add this.errorsLabel
-----------------------------------------------------------------------------------------
this.logsList = netClass.createCtl #ListView a:#Anchor v:"Left, Right, Top, Bottom" x:0 y:112 w:784 h:108
this.logsList.View = (netClass.getClass #View).Details
this.logsList.AllowColumnReorder = false
this.logsList.FullRowSelect = true
this.logsList.HeaderStyle = (netClass.getClass #ColumnHeaderStyle).Nonclickable
local image_list_small = netClass.createImageList #Image icon_path
local image_list_large = netClass.createImageList #Image icon_path
this.logsList.SmallImageList = image_list_small
this.logsList.LargeImageList = image_list_large
this.logsList.Columns.Add "Steps" 60
this.logsList.Columns.Add "Type" 72
this.logsList.Columns.Add "Message" 668
this.mainForm.Controls.Add this.logsList
dotnet.addeventhandler this.logsList "ColumnWidthChanging" columnWidthChangingEvent
),
on create do
(
this.createUI()
)
)
M3G_ImportInfo_Glb.DetailsUI = M3S_DetailsForm()
rollout M3P_About_UI "About" width:450 height:240
(
label lbl1 "Thanks" pos:[32,32] width:450 height:408
on M3P_About_UI open do
(
lbl1.text = "Big thanks to :\n" + \
" Taylormouse, (The M3 file's data structure is based on his script.)\n" + \
" Delphinium(Frog), (My first 3dsMax's teacher.)\n" + \
" Ò»Ò¶¾¡Êé·±»ª, (He helped build the DLL libraries for Textures Fix Tool,\n" + \
" and helped me tested the script.)\n" + \
" werd, (Helped me tested the script.)\n" + \
"\n" + \
"Scripted by CaptainD,Thank you for using it!"
)
on M3P_About_UI close do
(
)
)
rollout M3P_Missing_Map "Missing TextureMaps!" width:528 height:440
(
label lbl1 "Following textures are MISSING !!!" pos:[32,32] width:464 height:408
on M3P_Missing_Map open do
(
local text_show = ""
for i=1 to M3G_ImportInfo_Glb.missingMap.count do
(
append text_show (M3G_ImportInfo_Glb.missingMap[i] + ",\n")
)
lbl1.text = lbl1.text + "\n" + text_show + \
"Please put the textures in 3dsmax's textures path or \"(your model file path)/Assets/Textures\""
)
on M3P_Missing_Map close do
(
lbl1.text = "Following textures are MISSING !!!"
)
)
rollout M3P_Import_UI "Import Settings" width:200 height:504
(
groupBox Import_Grp "Import" pos:[8,8] width:184 height:272
editText Import_Path "" pos:[16,23] width:168 height:17 ReadOnly:true labelOnTop:true
label File_Name "None" pos:[44,48] width:140 height:17
button Select_File_Btn "Select File ..." pos:[24,72] width:152 height:32
button Import_Btn "Import" pos:[24,112] width:152 height:32
progressBar ProgressLv "" pos:[16,152] width:168 height:10 color:(color 32 168 0)
label Progress_text "" pos:[52,164] width:132 height:17
checkbox Show_Details_Check "" pos:[24,184] width:16 height:16
checkbox Miss_Texture_Check "" pos:[24,200] width:16 height:16 checked:true
checkButton Show_Details_Btn "Info" pos:[152,184] width:32 height:32
editText Map_Path "" pos:[16,224] width:168 height:17 ReadOnly:true labelOnTop:true
dropDownList Map_Source "" pos:[16,248] width:104 height:22 \
items:#("(m3Path)", "\\Texutures", "\\Assets\\Textures", "User Select") selection:2
button Select_MapPath_Btn "Select" pos:[128,248] width:56 height:24
checkbox Anim_Track_Check "" pos:[16,288] width:16 height:16 checked:true
checkbox Anim_Seq_Check "" pos:[16,304] width:16 height:16 checked:true
checkbox Anim_Check "" pos:[16,320] width:16 height:16 checked:true
checkbox Events_Check "" pos:[16,344] width:16 height:16 checked:true
checkbox Turret_Check "" pos:[96,344] width:16 height:16 checked:true
checkbox BBoard_Check "" pos:[16,360] width:16 height:16 checked:true
checkbox IK_Check "" pos:[96,360] width:16 height:16 checked:true
checkbox Materials_Check "" pos:[16,384] width:16 height:16 checked:true
checkbox Bones_Check "" pos:[96,384] width:16 height:16 checked:true
checkbox Meshes_Check "" pos:[16,400] width:16 height:16 checked:true
checkbox Skin_Check "" pos:[96,400] width:16 height:16 checked:true
checkbox Hit_Tests_Check "" pos:[16,424] width:16 height:16 checked:true
checkbox Vol_Targets_Check "" pos:[96,424] width:16 height:16 checked:true
checkbox Attachments_Check "" pos:[16,440] width:16 height:16 checked:true
checkbox Bounds_Check "" pos:[96,440] width:16 height:16 checked:true
checkbox Lights_Check "" pos:[16,464] width:16 height:16 checked:true
checkbox Cameras_Check "" pos:[96,464] width:16 height:16 enabled:true checked:true
checkbox Particles_Check "" pos:[16,480] width:16 height:16 checked:true
checkbox Physics_Check "" pos:[96,480] width:16 height:16 checked:true
label Import_Lbl_1 "File:" pos:[16,48] width:28 height:16
label Import_Lbl_2 "Phase:" pos:[16,164] width:32 height:16
label Import_Lbl_3 "Show Details Info" pos:[40,184] width:112 height:16
label Import_Lbl_4 "Missing Textures Info" pos:[40,200] width:112 height:16
label Import_Lbl_5 "Anim TrackSet" pos:[32,288] width:152 height:16
label Import_Lbl_6 "Anim Sequences" pos:[32,304] width:152 height:16
label Import_Lbl_7 "Animations" pos:[32,320] width:152 height:16
label Import_Lbl_8 "Events" pos:[32,344] width:64 height:16
label Import_Lbl_9 "Turrets" pos:[112,344] width:72 height:16
label Import_Lbl_10 "Billboards" pos:[32,360] width:64 height:16
label Import_Lbl_11 "IK Legs" pos:[112,360] width:72 height:16
label Import_Lbl_12 "Materials" pos:[32,384] width:64 height:16
label Import_Lbl_13 "Bones" pos:[112,384] width:72 height:16
label Import_Lbl_14 "Meshes" pos:[32,400] width:64 height:16
label Import_Lbl_15 "Skin" pos:[112,400] width:72 height:16
label Import_Lbl_16 "Hit Tests" pos:[32,424] width:64 height:16
label Import_Lbl_17 "Volume Targets" pos:[112,424] width:72 height:16
label Import_Lbl_18 "Attachments" pos:[32,440] width:64 height:16
label Import_Lbl_19 "Bounds" pos:[112,440] width:72 height:16
label Import_Lbl_20 "Lights" pos:[32,464] width:64 height:16
label Import_Lbl_21 "Cameras" pos:[112,464] width:72 height:16
label Import_Lbl_22 "Particles" pos:[32,480] width:64 height:16
label Import_Lbl_23 "Physics Sys" pos:[112,480] width:72 height:16
fn TranslateLanguage =
(
local language = copy M3G_ImportInfo_Glb.Language.value
Import_Grp.text = M3F_ReadLanguage language "Import" "Import"
Select_File_Btn.text = M3F_ReadLanguage language "Select_Btn" "Select File ..."
Import_Btn.text = M3F_ReadLanguage language "Import_Btn" "Import"
Import_Lbl_1.text = M3F_ReadLanguage language "File" "File:"
Import_Lbl_2.text = M3F_ReadLanguage language "Phase" "Phase:"
Import_Lbl_3.text = M3F_ReadLanguage language "ShowDetailsInfo" "Show Details Info"
Import_Lbl_4.text = M3F_ReadLanguage language "MissingTexturesInfo" "Missing Textures Info"
Show_Details_Btn.text = M3F_ReadLanguage language "ShowDetails_Btn" "Info"
Select_MapPath_Btn.text = M3F_ReadLanguage language "Select_MapPath_Btn" "PathSelect"
Import_Lbl_5.text = M3F_ReadLanguage language "AnimTrackSetEnable" "Anim TrackSet"