-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathM3 Import MiscUtil.ms
1496 lines (1356 loc) · 47.7 KB
/
M3 Import MiscUtil.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
rollout M3P_TexToolWaitUI "Wait" width:170 height:70
(
label wait_label "Waiting for finished..." pos:[32,32] height:160 width:360
)
rollout M3P_TexToolUI "Textures Fix Tool" height:500 width:800
(
local local_language = "English"
local Splitter_dis = 400
local texCheckAll = false
local pathCheckAll = false
local source_changed = false
local searched = 0
local tex_source = 1
local use_m3path = true
local root_enable = true
local copy_enable = false
local subfolder_enable = true
local casc_enable = false
local root_path = ""
local search_paths = #("(RootPath)\\", \
"(RootPath)\\Textures\\", \
"(RootPath)\\Assets\\Textures\\")
local search_path_enables = #(true, true, true)
local copy_path = ""
local split_container
local def_label
local red_label1
local yellow_label1
local tex_list_view
local path_list_view
local tex_group
local tex_btn
local source_radio_btn1
local source_radio_btn2
local use_m3path_cbox
local source_path_text
local source_select_btn
local root_cbox
local root_path_text
local root_path_select_btn
local path_add_btn
local path_delete_btn
local path_default_btn
local path_subfolder_cbox
local casc_cbox
local copy_cbox
local copy_path_text
local copy_path_select_btn
local language_ddl
local search_btn
local apply_btn
dotNetControl panel_container "System.Windows.Forms.Panel" pos:[8,8] align:#left height:484 width:784
fn translateLanguage =
(
def_label.Text = \
M3F_ReadLanguage local_language "TexTool_ColDef" "ColDefinition:"
red_label1.Text = \
M3F_ReadLanguage local_language "TexTool_ColNot" "Texture not exist"
yellow_label1.Text = \
M3F_ReadLanguage local_language "TexTool_ColApply" "Path not apply"
tex_list_view.Columns.Item[1].Text = \
M3F_ReadLanguage local_language "TexTool_TexListTex" "Textures"
tex_list_view.Columns.Item[2].Text = \
M3F_ReadLanguage local_language "TexTool_TexListPath" "Paths"
tex_group.Text = \
M3F_ReadLanguage local_language "TexTool_TexGroup" "Textures"
source_radio_btn1.Text = \
M3F_ReadLanguage local_language "TexTool_TexFrom1" "Textures from scene"
source_radio_btn2.Text = \
M3F_ReadLanguage local_language "TexTool_TexFrom2" "Textures from file"
use_m3path_cbox.Text = \
M3F_ReadLanguage local_language "TexTool_TexRootEnable" "(Use FilePath as RootPath)"
source_select_btn.Text = \
M3F_ReadLanguage local_language "TexTool_TexSlt" "Select"
root_cbox.Text = \
M3F_ReadLanguage local_language "TexTool_RootEnable" "Root Path:"
root_path_select_btn.Text = \
M3F_ReadLanguage local_language "TexTool_RootSlt" "Select"
path_subfolder_cbox.Text = \
M3F_ReadLanguage local_language "TexTool_PathSubEnable" "Search subfolders"
casc_cbox.Text = \
M3F_ReadLanguage local_language "TexTool_PathCASC" "Search file from CASC"
path_list_view.Columns.Item[1].Text = \
M3F_ReadLanguage local_language "TexTool_PathListPath" "Search Paths"
copy_cbox.Text = \
M3F_ReadLanguage local_language "TexTool_CopyEnable" "Copy found textures to:"
copy_path_select_btn.Text = \
M3F_ReadLanguage local_language "TexTool_CopySlt" "Select"
search_btn.Text = \
M3F_ReadLanguage local_language "TexTool_SearchBtn" "Search"
apply_btn.Text = \
M3F_ReadLanguage local_language "TexTool_ApplyBtn" "Apply"
)
fn checkCASCpathList =
(
if(M3G_ImportInfo_Glb.texToolUI.CASCpathList.count == 0)then
(
undo off
(
try(gc())catch()
local time_ = timeStamp()
/*
local data_stream = MemStreamMgr.openFile "$plugcfg\\SC2DataIndex\\.SC2Index" \
favor_type:#FAVOR_UTF8
if(data_stream != undefined)then
(
while(not data_stream.eos())do
(
local data_path = data_stream.readLine()
local data_name = toLower (filenameFromPath data_path)
if(data_name != data_path)then
(
append M3G_ImportInfo_Glb.texToolUI.CASCpathList data_name
append M3G_ImportInfo_Glb.texToolUI.CASCpathList data_path
)
)
MemStreamMgr.close data_stream
)
--*/
local data_stream = openFile "$plugcfg\\SC2DataIndex\\.SC2Index" mode:"rt"
if(data_stream != undefined)then
(
while(not (eof data_stream))do
(
local data_path = readLine data_stream
local data_name = toLower (filenameFromPath data_path)
if(data_name != data_path)then
(
append M3G_ImportInfo_Glb.texToolUI.CASCpathList data_name
append M3G_ImportInfo_Glb.texToolUI.CASCpathList data_path
)
)
close data_stream
)
format "readIndex: % ms\n" (timestamp()-time_)
)
)
)
fn createCASCindex =
(
local i
local idx_changed = false
if(M3F_CheckStarTools #Info func:#gameDir)then
(local game_dir = StarTools.Info.GetDir #localBuild)else(return false)
if((doesFileExist "$plugcfg\\SC2DataIndex\\Temp") != true)then
(
makeDir "$plugcfg\\SC2DataIndex\\Temp" all:true
)
local delete_temp = getFiles "$plugcfg\\SC2DataIndex\\Temp\\*.*"
for i in delete_temp do(deleteFile i)
local idx_files = getFiles (game_dir + "\\SC2Data\\data\\*.idx")
local old_idx_files = getFiles "$plugcfg\\SC2DataIndex\\*.idx"
for i=1 to old_idx_files.count do(old_idx_files[i] = filenameFromPath old_idx_files[i])
for i in idx_files do
(
local file_name = filenameFromPath i
local check_names = filterString (toLower file_name) "0123456789abcdef"
local check_type = subString (toLower file_name) 11 -1
if(check_names[1] == ".i" and check_names[2] == "x" and check_type == ".idx")then
(
local find = findItem old_idx_files file_name
if(find > 0)then
(
local old_path = "$plugcfg\\SC2DataIndex\\" + file_name
local old_date = getFileModDate old_path
try(local new_date = getFileModDate i)catch
(
local temp_file = (i+"_copy")
copyFile i temp_file
local new_date = getFileModDate temp_file
deleteFile temp_file
)
if(old_date != new_date)then
(
idx_changed = true
deleteFile old_path
copyFile i old_path
)
deleteItem old_idx_files find
)else
(
idx_changed = true
copyFile i ("$plugcfg\\SC2DataIndex\\" + file_name)
)
)
)
for i in old_idx_files do
(
idx_changed = true
deleteFile ("$plugcfg\\SC2DataIndex\\" + i)
)
if((doesFileExist "$plugcfg\\SC2DataIndex\\.SC2Index") != true)then(idx_changed = true)
if(idx_changed)then
(
deleteFile "$plugcfg\\SC2DataIndex\\.SC2Index"
local check_select = queryBox ("***SC2DataIndex has changed.***\n\n" + \
"The script needs to build the entire data index files.\n" + \
"*Notice:It will take 1 to 2 minutes to continue.") \
title:"Need rebuild SC2DataIndex !!!" beep:true
if(check_select)then
(
undo off
(
local time_ = timeStamp()
CreateDialog M3P_TexToolWaitUI style:#(#style_border) lockHeight:true lockWidth:true
local result = M3G_ImportInfo_Glb.ExtractFileLib.WriteStorage \
(game_dir + "\\SC2Data\\data") \
(pathConfig.resolvePathSymbols "$plugcfg\\SC2DataIndex") \
(pathConfig.resolvePathSymbols "$plugcfg\\SC2DataIndex\\.SC2Index")
format "Build:% ms\n" (timestamp()-time_)
if(result == 0)then
(
M3G_ImportInfo_Glb.texToolUI.CASCpathList = #()
checkCASCpathList()
try(destroyDialog M3P_TexToolWaitUI)catch()
true
)else
(
local delete_files = getFiles "$plugcfg\\SC2DataIndex\\*.idx"
for i in delete_files do(deleteFile i)
try(destroyDialog M3P_TexToolWaitUI)catch()
false
)
)
)else
(
local delete_files = getFiles "$plugcfg\\SC2DataIndex\\*.idx"
for i in delete_files do(deleteFile i)
false
)
)else
(
CreateDialog M3P_TexToolWaitUI style:#(#style_border) lockHeight:true lockWidth:true
checkCASCpathList()
try(destroyDialog M3P_TexToolWaitUI)catch()
true
)
)
fn expandRootPath path_FP =
(
local expand_path = copy path_FP
local real_root_path = if(use_m3path and use_m3path_cbox.Enabled)then
(
getFilenamePath source_path_text.Text
)else
(
if(root_enable and root_cbox.Enabled)then(root_path)else("")
)
if(matchPattern expand_path pattern:"(RootPath)\\*" ignoreCase:false)then
(
if(real_root_path.count > 0)then
(
expand_path = (real_root_path + (subString expand_path 12 -1))
)else
(
expand_path = ""
)
)
expand_path
)
fn checkRootPath =
(
local i
local netClass = M3S_DotNetClass()
local back_color = if(use_m3path and use_m3path_cbox.Enabled)then
(
if((getFilenamePath source_path_text.Text).count > 0)then(#(255,255,255))else(#(255,0,0))
)else
(
if(root_enable and root_path_text.Text.count > 0)then(#(255,255,255))else(#(255,0,0))
)
if(matchPattern copy_path pattern:"(RootPath)\\*")then
(
copy_path_text.BackColor = \
(netClass.getClass #Color).FromArgb back_color[1] back_color[2] back_color[3]
)
for i=0 to (path_list_view.Items.Count-1) do
(
if(matchPattern path_list_view.Items.Item[i].SubItems.Item[1].Text pattern:"(RootPath)\\*")then
(
path_list_view.Items.Item[i].BackColor = \
(netClass.getClass #Color).FromArgb back_color[1] back_color[2] back_color[3]
)
)
)
fn findTextures tex_paths_FP =
(
local i, n, k
local path_list = #()
local ret_list = deepCopy tex_paths_FP
if(copy_enable and copy_path.count > 0)then
(
local expand_path = expandRootPath copy_path
if(expand_path.count > 0)then(appendIfUnique path_list expand_path)
)
for i=1 to search_paths.count do
(
if(search_path_enables[i])then
(
local expand_path = expandRootPath search_paths[i]
if(expand_path.count > 0)then
(
appendIfUnique path_list expand_path
if(subfolder_enable)then
(
local sub_path_list = #(expand_path)
n = 0
while n < sub_path_list.count do
(
n = n + 1
local find_sub = getDirectories (sub_path_list[n] + "*")
for k in find_sub do
(
appendIfUnique sub_path_list k
)
)
for n in sub_path_list do
(
appendIfUnique path_list n
)
)
)
)
)
for i=1 to path_list.count do
(
mapPaths.add path_list[i]
for n=1 to tex_paths_FP.count do
(
local map_name = filenameFromPath tex_paths_FP[n]
local path_found = (mapPaths.getFullFilePath map_name)
if(path_found != "" and (ret_list[n] == tex_paths_FP[n]))then(ret_list[n] = path_found)
)
try(mapPaths.delete (mapPaths.count()))catch()
)
ret_list
)
fn getSC2MatList =
(
local i, n
local mat_list = #()
local mat_list_check = #()
for i in sceneMaterials do(appendIfUnique mat_list_check i)
for i in meditMaterials do(appendIfUnique mat_list_check i)
for i in objects where classOf i == SC2LensFlare do(appendIfUnique mat_list_check i.lensFlareMaterial)
for i in mat_list_check do
(
case (classOf i) of
(
SC2_Standard_Material: appendIfUnique mat_list i
SC2_Composite_Material:
(
for n in i.SubMaterials where n != undefined do(appendIfUnique mat_list n)
)
SC2_Displacement_Material: appendIfUnique mat_list i
SC2_Terrain_Material: appendIfUnique mat_list i
SC2_Volume_Material: appendIfUnique mat_list i
SC2_Creep_Material: appendIfUnique mat_list i
SC2_Volume_Noise_Material: appendIfUnique mat_list i
SC2_SplatTerrainBake_Material: appendIfUnique mat_list i
SC2_Reflection_Material: appendIfUnique mat_list i
SC2_Lens_Flare_Material: appendIfUnique mat_list i
)
)
mat_list
)
fn getBitmapName mat_FP =
(
local bitmap_name = #()
case (classOf mat_FP) of
(
SC2_Standard_Material:
(
bitmap_name = #(#Diffuse, #Decal, #Gloss, #Emissive1, #Emissive2, #Environment, \
#EnvironmentMask, #AlphaMask, #NormalMap, #Heightmap, #Lightmap, #AmbientOcclusion, \
#AlphaMask2, #GlossExp, #NormBlendMask1, #NormBlendMask2, #NormBlendNormal1, #NormBlendNormal2)
)
SC2_Displacement_Material:
(
bitmap_name = #(#Displacement, #DisplacementStrengthTexture)
)
SC2_Terrain_Material:
(
bitmap_name = #(#TerrainMaterial)
)
SC2_Volume_Material:
(
bitmap_name = #(#ColorMap, #Noisy1, #Noisy2)
)
SC2_Creep_Material:
(
bitmap_name = #(#CreepMaterial)
)
SC2_Volume_Noise_Material:
(
bitmap_name = #(#ColorMap, #VolumeNoise1, #VolumeNoise2)
)
SC2_SplatTerrainBake_Material:
(
bitmap_name = #(#DiffuseTexture, #NormalTexture, #SpecularTexture)
)
SC2_Reflection_Material:
(
bitmap_name = #(#Strength_Map, #Normal_Map, #Blur_Mask_Map)
)
SC2_Lens_Flare_Material:
(
bitmap_name = #(#Normal_Map, #Dirty_Lens)
)
)
bitmap_name
)
fn texListRefresh source_FP =
(
local i, n, k
local tex_list = #()
local netClass = M3S_DotNetClass()
if(source_FP == 1)then
(
local mat_list = getSC2MatList()
for n in mat_list do
(
local bitmap_name = getBitmapName n
for k in bitmap_name do
(
local file_str = try((getProperty n k).FileName)catch("")
if(file_str.count > 0)then
(
appendIfUnique tex_list file_str
)
)
)
)else
(
local streamR
local file_path = source_path_text.Text
local related_path = getFilenamePath file_path
if(doesFileExist file_path)then
(
streamR = fOpen file_path "rb"
local m3model = M3S_FileMain()
local max_scene = M3S_SceneMain()
m3model.readMaterials streamR
fClose streamR
max_scene.buildMaterialsData m3model
for i=1 to max_scene.sMaterial.count do
(
for n=1 to max_scene.sMaterial[i].mapsData.count do
(
if(max_scene.sMaterial[i].mapsData[n].MapType == 1)then
(
local tex_file_name = try(copy max_scene.sMaterial[i].mapsData[n].FileName)catch("")
if(tex_file_name != "")then
(appendIfUnique tex_list tex_file_name)
)
)
)
tex_list = findTextures tex_list
)
)
local items_list = #()
tex_list_view.Items.Clear()
for i=1 to tex_list.count do
(
local texture_str = filenameFromPath tex_list[i]
local path_str = getFilenamePath tex_list[i]
append items_list (netClass.createCtl #ListViewItem)
items_list[items_list.count].Checked = true
items_list[items_list.count].SubItems.Add texture_str
items_list[items_list.count].SubItems.Add path_str
if((doesFileExist tex_list[i]) != true)then
(
items_list[items_list.count].Name = "NotFound"
items_list[items_list.count].BackColor = (netClass.getClass #Color).FromArgb 0xFFFF0000
)
)
tex_list_view.Items.AddRange items_list
)
fn texRefreshBtn sender_FP e_FP =
(
texListRefresh tex_source
source_changed = false
searched = 0
)
fn texSourceRBtnSelect sender_FP e_FP =
(
if(sender_FP.Checked == false)then(return false)
case sender_FP.Name of
(
"source_radio_btn1":
(
tex_source = 1
source_path_text.Enabled = false
source_select_btn.Enabled = false
use_m3path_cbox.Enabled = false
root_cbox.Enabled = true
root_path_text.Enabled = root_enable
root_path_select_btn.Enabled = root_enable
)
"source_radio_btn2":
(
tex_source = 2
source_path_text.Enabled = true
source_select_btn.Enabled = true
use_m3path_cbox.Enabled = true
root_cbox.Enabled = if(use_m3path)then(false)else(true)
root_path_text.Enabled = if(use_m3path)then(false)else(root_enable)
root_path_select_btn.Enabled = if(use_m3path)then(false)else(root_enable)
)
)
source_changed = true
checkRootPath()
)
fn selectPathBtn sender_FP e_FP =
(
if(sender_FP.Name == "copy_path_select_btn" or sender_FP.Name == "path_add_btn")then
(
local save_path = getSaveFileName \
caption:"Select a path" \
filename:".savePath" \
types:"Folder|.savePath|" \
historyCategory:"Star2PresetFolder"
if(save_path != undefined)then
(
save_path = getFilenamePath save_path
if(use_m3path and use_m3path_cbox.Enabled)then
(
local source_path = source_path_text.Text
if(source_path.count > 0)then
(
source_path = getFilenamePath source_path
if(matchPattern save_path pattern:(source_path+"*") ignoreCase:false)then
(
save_path = "(RootPath)\\" + (subString save_path (source_path.count+1) -1)
)
)
)else
(
if(root_path.count > 0 and root_enable)then
(
if(matchPattern save_path pattern:(root_path+"*") ignoreCase:false)then
(
save_path = "(RootPath)\\" + (subString save_path (root_path.count+1) -1)
)
)
)
)
)
case sender_FP.Name of
(
"source_select_btn":
(
local file = getOpenFileName \
caption:"StarCraftII M3 File" \
types:("Supported Files|*.m3;*.m3a" + \
"|Starcraft 2 & Heroes of the Storm(*.m3)|*.m3" + \
"|Animation Files(*.m3a)|*.m3a" + \
"|All Files|*.*|") \
historyCategory:"Star2PresetFolder"
if(file != undefined)then
(
source_path_text.Text = file
source_changed = true
checkRootPath()
)
)
"root_path_select_btn":
(
local save_path = getSaveFileName \
caption:"Select a path" \
filename:".searchPath" \
types:"Folder|.searchPath|" \
historyCategory:"Star2PresetFolder"
if(save_path != undefined)then
(
save_path = getFilenamePath save_path
root_path_text.Text = save_path
root_path = save_path
if(searched == 1)then(searched = 2)
checkRootPath()
)
)
"copy_path_select_btn":
(
if(save_path != undefined)then
(
copy_path_text.Text = save_path
copy_path = save_path
if(searched == 1)then(searched = 2)
checkRootPath()
)
)
"path_add_btn":
(
local netClass = M3S_DotNetClass()
if(save_path != undefined)then
(
if((findItem search_paths save_path) == 0)then
(
append search_paths save_path
append search_path_enables true
local sub_item = netClass.createCtl #ListViewItem
sub_item.Checked = true
sub_item.SubItems.Add save_path
path_list_view.Items.Add sub_item
if(searched == 1)then(searched = 2)
checkRootPath()
)
)
)
)
)
fn pathDeleteBtn sender_FP e_FP =
(
local i = 0
while i < search_paths.count do
(
if(path_list_view.Items.Item[i].Checked != true)then
(
local find = findItem search_paths path_list_view.Items.Item[i].SubItems.Item[1].Text
deleteItem search_paths find
deleteItem search_path_enables find
path_list_view.Items.RemoveAt i
if(searched == 1)then(searched = 2)
i = i - 1
)
i = i + 1
)
)
fn pathDefaultBtn sender_FP e_FP =
(
local netClass = M3S_DotNetClass()
search_paths = #("(RootPath)\\", \
"(RootPath)\\Textures\\", \
"(RootPath)\\Assets\\Textures\\")
search_path_enables = #(true, true, true)
path_list_view.Items.Clear()
for i=1 to search_paths.count do
(
local sub_item = netClass.createCtl #ListViewItem
sub_item.Checked = search_path_enables[i]
sub_item.SubItems.Add search_paths[i]
path_list_view.Items.Add sub_item
)
if(searched == 1)then(searched = 2)
checkRootPath()
)
fn enabledCBox sender_FP e_FP =
(
case sender_FP.Name of
(
"root_cbox":
(
if(sender_FP.Checked == true)then
(
root_enable = true
root_path_text.Enabled = true
root_path_select_btn.Enabled = true
)else
(
root_enable = false
root_path_text.Enabled = false
root_path_select_btn.Enabled = false
)
if(searched == 1)then(searched = 2)
checkRootPath()
)
"copy_cbox":
(
if(sender_FP.Checked == true)then
(
copy_enable = true
copy_path_text.Enabled = true
copy_path_select_btn.Enabled = true
)else
(
copy_enable = false
copy_path_text.Enabled = false
copy_path_select_btn.Enabled = false
)
if(searched == 1)then(searched = 2)
)
"path_subfolder_cbox":
(
if(sender_FP.Checked == true)then
(
subfolder_enable = true
)else
(
subfolder_enable = false
)
if(searched == 1)then(searched = 2)
)
"use_m3path_cbox":
(
if(sender_FP.Checked == true)then
(
use_m3path = true
root_cbox.Enabled = false
root_path_text.Enabled = false
root_path_select_btn.Enabled = false
)else
(
use_m3path = false
root_cbox.Enabled = true
root_path_text.Enabled = root_enable
root_path_select_btn.Enabled = root_enable
)
if(searched == 1)then(searched = 2)
checkRootPath()
)
"casc_cbox":
(
if(sender_FP.Checked == true)then
(
if(createCASCindex())then
(
casc_enable = true
)else
(
sender_FP.Checked = false
casc_enable = false
)
)else
(
casc_enable = false
)
)
)
)
fn searchBtn sender_FP e_FP =
(
if(source_changed)then
(
messageBox "Please refresh textures list first!!!"
return false
)
if(searched == 2)then
(
texListRefresh tex_source
source_changed = false
)
searched = 1
if(M3F_CheckStarTools #Info func:#gameDir)then
(local game_dir = StarTools.Info.GetDir #localBuild)else(return false)
setWaitCursor()
local i
local netClass = M3S_DotNetClass()
local index_list = #()
local tex_list = #()
local path_list = #()
local expand_copy_path = if(copy_enable and copy_path.count > 0)then(expandRootPath copy_path)else("")
local expand_search_path = ""
for i=1 to search_paths.count do
(
if(search_path_enables[i] and search_paths[i].count > 0)then
(
expand_search_path = expandRootPath search_paths[i]
if(expand_search_path.count > 0)then(exit)
)
)
if(expand_search_path.count == 0 and expand_copy_path.count > 0)then
(expand_search_path = copy expand_copy_path)
for i=0 to (tex_list_view.Items.Count-1) do
(
if(tex_list_view.Items.Item[i].Checked and tex_list_view.Items.Item[i].Name == "NotFound")then
(
append index_list i
append tex_list (copy tex_list_view.Items.Item[i].SubItems.Item[1].Text)
)
)
CreateDialog M3P_TexToolWaitUI style:#(#style_border) lockHeight:true lockWidth:true
path_list = findTextures tex_list
local data_dir = game_dir + "\\SC2Data\\data"
local idx_dir = pathConfig.resolvePathSymbols "$plugcfg\\SC2DataIndex\\"
for i=1 to tex_list.count do
(
if(tex_list[i] != path_list[i])then
(
local index = index_list[i]
tex_list_view.Items.Item[index].Name = "NotApply"
tex_list_view.Items.Item[index].SubItems.Item[2].Text = getFilenamePath path_list[i]
tex_list_view.Items.Item[index].BackColor = (netClass.getClass #Color).FromArgb 0xFFFFFF00
)else
(
if(casc_enable and expand_search_path.count > 0)then
(
local file_exist = false
local file_copy_dir = idx_dir + "Temp\\" + tex_list[i]
if(doesFileExist file_copy_dir)then
(
file_exist = true
)else
(
local time_ = timestamp()
local file_name = toLower tex_list[i]
local find_index = findItem M3G_ImportInfo_Glb.texToolUI.CASCpathList file_name
local find_item = if(find_index != 0)then
(
M3G_ImportInfo_Glb.texToolUI.CASCpathList[find_index+1]
)else(undefined)
format "findItem:% file_name:%\n" find_item file_name
format "findItem: % ms\n" (timestamp()-time_)
if(find_item != undefined)then
(
time_ = timestamp()
local result = M3G_ImportInfo_Glb.ExtractFileLib.ExtractFile \
data_dir idx_dir find_item file_copy_dir
if(result == 0)then(file_exist = true)
format "ExtractFile: % ms\n" (timestamp()-time_)
windows.processPostedMessages()
setWaitCursor()
)
)
if(file_exist)then
(
local index = index_list[i]
tex_list_view.Items.Item[index].Name = "NotApplyCASC"
tex_list_view.Items.Item[index].SubItems.Item[2].Text = idx_dir + "Temp\\"
tex_list_view.Items.Item[index].BackColor = \
(netClass.getClass #Color).FromArgb 0xFFFFFF00
)
)
)
)
for i=0 to (tex_list_view.Items.Count-1) do
(
if(tex_list_view.Items.Item[i].Checked and tex_list_view.Items.Item[i].Name != "NotFound")then
(
if(expand_copy_path.count > 0)then
(
if(tex_list_view.Items.Item[i].SubItems.Item[2].Text != expand_copy_path)then
(
tex_list_view.Items.Item[i].Name = "NotApplyCopy"
local origin_path = tex_list_view.Items.Item[i].SubItems.Item[2].Text
if(tex_list_view.Items.Item[i].SubItems.Count == 3)then
(
tex_list_view.Items.Item[i].SubItems.Add origin_path
)else
(
tex_list_view.Items.Item[i].SubItems.Item[3].Text = origin_path
)
tex_list_view.Items.Item[i].SubItems.Item[2].Text = expand_copy_path
tex_list_view.Items.Item[i].BackColor = (netClass.getClass #Color).FromArgb 0xFFFFFF00
)
)else if(tex_list_view.Items.Item[i].Name == "NotApplyCASC")then
(
local origin_path = tex_list_view.Items.Item[i].SubItems.Item[2].Text
if(tex_list_view.Items.Item[i].SubItems.Count == 3)then
(
tex_list_view.Items.Item[i].SubItems.Add origin_path
)else
(
tex_list_view.Items.Item[i].SubItems.Item[3].Text = origin_path
)
tex_list_view.Items.Item[i].SubItems.Item[2].Text = expand_search_path
)
)
)
try(destroyDialog M3P_TexToolWaitUI)catch()
setArrowCursor()
)
fn applyBtn sender_FP e_FP =
(
if(source_changed)then
(
messageBox "Please refresh textures list first!!!"
return false
)
local i, n, k
local netClass = M3S_DotNetClass()
CreateDialog M3P_TexToolWaitUI style:#(#style_border) lockHeight:true lockWidth:true
local mat_list = getSC2MatList()
for i=0 to (tex_list_view.Items.Count-1) do
(
if(tex_list_view.Items.Item[i].Checked)then
(
local tex_type = tex_list_view.Items.Item[i].Name
if((tex_type == "NotApplyCopy" and copy_enable) or (tex_type == "NotApplyCASC"))then
(
local old_file_path = tex_list_view.Items.Item[i].SubItems.Item[3].Text + \
tex_list_view.Items.Item[i].SubItems.Item[1].Text
local new_file_path = tex_list_view.Items.Item[i].SubItems.Item[2].Text + \
tex_list_view.Items.Item[i].SubItems.Item[1].Text
makeDir tex_list_view.Items.Item[i].SubItems.Item[2].Text all:true
copyFile old_file_path new_file_path
)
if(tex_source == 1 and (matchPattern tex_list_view.Items.Item[i].Name pattern:"NotApply*"))then
(
local full_file_path = tex_list_view.Items.Item[i].SubItems.Item[2].Text + \
tex_list_view.Items.Item[i].SubItems.Item[1].Text
for n in mat_list do
(
local bitmap_name = getBitmapName n
for k in bitmap_name do
(
local bitmap_obj = getProperty n k
local file_str = try(bitmap_obj.FileName)catch("")
if(file_str.count > 0)then
(
local file_name = filenameFromPath file_str
if(file_name == tex_list_view.Items.Item[i].SubItems.Item[1].Text)then
(
bitmap_obj.FileName = full_file_path
)
)
)
)
)
)
)
texListRefresh tex_source
source_changed = false
try(destroyDialog M3P_TexToolWaitUI)catch()
)
fn pathListItemCheck sender_FP e_FP =
(
local find = findItem search_paths path_list_view.Items.Item[e_FP.Index].SubItems.Item[1].Text
if(e_FP.CurrentValue == e_FP.CurrentValue.Unchecked)then
(
search_path_enables[find] = true
)else
(
search_path_enables[find] = false
)
if(searched == 1)then(searched = 2)
)
fn pathListItemDrag sender_FP e_FP =
(