1-- NW4C Menu Script(2010/10/20)
2-- Version 0.4.7
3-- (c)2010 Nintendo
4
5fileIn  "NW4C_utils.ms.inc"
6
7rollout nw4cExportRollout "NW4C Export Setting" width:480 height:696
8(
9	local utils = nw4c_utils()
10
11	groupBox grpOutputOptions "Output Options" pos:[7,8] width:464 height:104
12	--group "Output Options"
13	--(
14		label lbl4 "Export Target" pos:[16,24] width:96 height:20
15		radioButtons rdoSelection "" pos:[120,24] width:80 height:16 labels:#("All", "Selection") columns:2
16		checkbox chkUseCS "Use Creative Studio" pos:[310,24] width:160 height:16
17		label lbl2 "File name:" pos:[16,44] width:72 height:20
18		editText editFilename "" pos:[96,44] width:264
19		button btnNameNode "Node" pos:[362,44] width:48 height:16
20		button btnNameScene "Scene" pos:[416,44] width:48 height:16
21		label lbl1 "File path:" pos:[16,66] width:72 height:20
22		editText editFilepath "" pos:[96,66] width:341
23		button btnSelectPath "+" pos:[440,66] width:20 height:16 toolTip:"Select folder"
24		checkbox chkMergeCmdl "Merge cmdl" pos:[16,88] width:80 height:16
25		editText editMergeFile "" pos:[96,88] width:341
26		button btnSelectMerge "+" pos:[440,88] width:20 height:16 toolTip:"Select Merge File"
27	--)
28	groupBox grpGeneralOptions "General Options" pos:[8,120] width:464 height:64
29	--group "General Options"
30	--(
31		spinner spnMagnify "Magnify: " pos:[40,136] width:120 height:16 range:[0.0001,10000,1] type:#float scale:0.1
32		label lbl8 "Start/End Frame:" pos:[16,160] width:112 height:20
33		radioButtons rdoTimeRange "" pos:[128,160] width:104 height:16 labels:#("All", "Range") columns:2
34		spinner spnTimeStart "" pos:[248,160] width:64 height:16 range:[0,100000,0] type:#integer scale:1
35		spinner spnTimeEnd "" pos:[320,160] width:64 height:16 range:[0,100000,100] type:#integer scale:1
36		checkbox chkUseFigureMode "Use FigureMode and SkinPose" pos:[216,136] width:240 height:16 checked:false
37	--)
38	groupBox grpOutputFileSelection "Output File Selection" pos:[8,192] width:464 height:88
39	--group "Output File Selection"
40	--(
41		checkbox chkExportModel "Model Data (.cmdl)" pos:[24,208] width:208 height:16 checked:true
42		checkbox chkExportTex "Texture Data (.ctex)" pos:[24,224] width:208 height:16  checked:true
43		checkbox chkExportSkelAnim "Skeletal Animation Data (.cskla)" pos:[24,240] width:208 height:16 checked:true
44		checkbox chkExportCamera "Camera Data (.ccam)" pos:[260,208] width:208 height:16 checked:true
45		checkbox chkExportLight "Light Data (.clgt)" pos:[260,224] width:208 height:16 checked:true
46		checkbox chkExportMtlAnim "Material Animation Data(.cmata)" pos:[260,240] width:208 height:16 checked:false
47		checkbox chkExportMdlAnim "Model Animation Data(.cmdla)" pos:[24,256] width:208 height:16 checked:false--enabled:false
48		checkbox chkExportEnv "Environment Data(.env)" pos:[260,256] width:208 height:16 checked:false--enabled:false
49	--)
50	groupBox grpOptimizationOptions "Optimization Options" pos:[8,288] width:464 height:60
51	--group "Optimization Options"
52	--(
53		dropDownList ddlCompressNode "Compress Node" pos:[12,304] width:140 height:41 \
54			items:#("None", "Cull Useless Node", "Cull Uninfluential Node", "Unite Compressible Node", "Unite All Node") --, "Unite Below Node")
55		dropDownList ddlOptimizeMtl "Compress Material" pos:[158,304] width:140 height:41  items:#("None", "Compress Same Material")
56		checkbox chkOptimizePrim "Optimize Primitive" pos:[304,298] width:166 height:16
57		--checkbox chkOptimizeMtl "Compress Material" pos:[320,304] width:120 height:16
58		checkbox chkDisableSimplification "Disable SkeletalModel- Simplification" pos:[304,316] width:166 height:28
59	--)
60	groupBox grpQuantizationOptions "Quantization Options" pos:[8,352] width:464 height:58
61	--group "Quantization Options"
62	--(
63		dropDownList ddlQuantPosition "Position" pos:[24,368] width:64 height:41  items:#("Float", "Short", "Byte")
64		dropDownList ddlQuantNormal "Normal" pos:[96,368] width:64 height:41  items:#("Float", "Short", "Byte")
65		dropDownList ddlQuantTex "Tex Coord" pos:[168,368] width:64 height:41  items:#("Float", "Short", "Byte")
66		--spinner spnPrecisionTrans "Translate Precision:" pos:[340,368] width:80 height:16  range:[0.0001,100,0.01] type:#float scale:0.01
67		--spinner spnPrecisionRotate "Rotate Precision:" pos:[342,392] width:78 height:16  range:[0.0001,100,0.01] type:#float scale:0.01
68		--spinner spnPrecisionScale "Scale Precision:" pos:[344,416] width:76 height:16  range:[0.0001,100,0.01] type:#float scale:0.01
69		--checkbox chkFrameFormat "Frame Format" pos:[24,416] width:208 height:16 checked:false
70
71	--)
72	groupBox grpModelOptions "Model Options" pos:[8,412] width:464 height:64
73	--group "Model Options"
74	--(
75		checkbox chkNonUniformScale "Non-Uniform Scale" pos:[16,426] width:140 height:16 checked:true
76		spinner spnReserveUniform "Max Reserved Uniform Registers:" pos:[160,450] width:80 height:16  range:[0,60,0] type:#integer scale:1
77		dropDownList ddlModelBindBy "Mesh Visibility Mode" pos:[260,426] width:120 height:41  items:#("Bind By Index", "Bind By Name")
78	--)
79	groupBox grpAnimationOptions "Animation Options" pos:[8,482] width:464 height:78
80	--group "Animation Options"
81	--(
82		dropDownList ddlAnimationPrecision "Frame Precision" pos:[24,496] width:104 height:41 items:#("1.0", "0.5", "0.2", "0.1") --enabled:false
83		checkbox chkAnimationLoop "Loop" pos:[144,496] width:80 height:16
84		label lbl9 "Frame Format:" pos:[24,540] width:80 height:16
85		radioButtons rdoFrameFormat "" pos:[104,540] width:164 height:16 labels:#("Key Frame", "Full Frame") columns:2
86		spinner spnScaleQuality "    Scale Quantize Quality:" pos:[400,498] width:60 height:16  range:[0,9,9] type:#integer
87		spinner spnRotateQuality "   Rotate Quantize Quality:" pos:[400,518] width:60 height:16  range:[0,9,9] type:#integer
88		spinner spnTransQuality "Translate Quantize Quality:" pos:[400,538] width:60 height:16  range:[0,9,9] type:#integer
89	--)
90	groupBox grpToleranceOptions "Tolerance Options" pos:[8,568] width:464 height:88
91	--group "Tolerance Options"
92	--(
93		spinner spnToleranceNodeT "Node Translate:" pos:[80,584] width:80 height:16  range:[0.0001,100,0.01] type:#float scale:0.01
94		spinner spnToleranceNodeR "Node Rotate:" pos:[82,608] width:78 height:16  range:[0.0001,100,0.1] type:#float scale:0.01
95		spinner spnToleranceNodeS "Node Scale:" pos:[84,632] width:76 height:16  range:[0.0001,100,0.1] type:#float scale:0.01
96		spinner spnToleranceTexT "Tex Translate:" pos:[244,584] width:80 height:16   range:[0.0001,100,0.01] type:#float scale:0.01
97		spinner spnToleranceTexR "Tex Rotate:" pos:[246,608] width:78 height:16 range:[0.0001,100,0.1] type:#float scale:0.01
98		spinner spnToleranceTexS "Tex Scale:" pos:[248,632] width:76 height:16 range:[0.0001,100,0.1] type:#float scale:0.01
99		spinner spnToleranceColor "Color:" pos:[360,584] width:80 height:16 range:[0.0001,100,0.001] type:#float scale:0.01
100	--)
101
102	button btnExport "Export" pos:[16,664] width:144 height:24
103	button btnApply "Apply" pos:[168,664] width:144 height:24
104	button btnClose "Close" pos:[320,664] width:144 height:24
105
106	fn redrawItems =
107	(
108		spnTimeStart.enabled = spnTimeEnd.enabled = (rdoTimeRange.state == 2)
109		editMergeFile.visible = btnSelectMerge.visible = chkMergeCmdl.state
110		editFilepath.enabled = btnSelectPath.enabled = not chkUseCS.state
111	)
112
113	fn loadConfig loadFromScene:true =
114	(
115		--print "load config"
116		local nw4c = nw4cmax
117		if loadFromScene do nw4c.LoadSetting()
118		editFilepath.text = nw4c.outFolder
119		editFilename.text = nw4c.filename
120		chkUseCS.state = nw4c.UseCreativeStudio
121
122		chkExportModel.state = nw4c.doesExportModel
123		chkExportTex.state = nw4c.doesExportTexture
124		chkExportSkelAnim.state = nw4c.doesExportAnimation
125		chkExportCamera.state = nw4c.doesExportCamera
126		chkExportLight.state = nw4c.doesExportLight
127		chkExportMtlAnim.state = nw4c.doesExportMtlAnim
128		chkExportMdlAnim.state = nw4c.doesExportModelAnim
129		chkExportEnv.state = nw4c.doesExportEnv
130
131		--
132		rdoSelection.state = (if nw4c.doesExportSelected then 2 else 1)
133		--
134		spnMagnify.value = nw4c.Magnify
135		--
136		rdoTimeRange.state = (if nw4c.doesExportAllFrames then 1 else 2)
137		spnTimeStart.value = nw4c.StartFrame
138		spnTimeEnd.value = nw4c.EndFrame
139		chkAnimationLoop.state = nw4c.IsLoop
140		ddlAnimationPrecision.selection = case of
141		(
142				(1 >= nw4c.AnimPrecision) : 1
143				(2 >= nw4c.AnimPrecision) : 2
144				(5 >= nw4c.AnimPrecision) : 3
145				(10 >= nw4c.AnimPrecision) : 4
146				default: 1
147		)
148		--
149		ddlCompressNode.selection = if nw4c.CompressNode == 6 then 1 else nw4c.CompressNode -- Unite Bleow Node��p�~
150		chkOptimizePrim.state = nw4c.OptimizePrimitive
151		--chkOptimizeMtl.state = nw4c.OptimizeMaterial
152		ddlOptimizeMtl.selection = if nw4c.OptimizeMaterial then 2 else 1
153		chkDisableSimplification.state = nw4c.DisableModelSimplification
154		chkNonUniformScale.state = nw4c.NonUniformScale
155		spnReserveUniform.value = nw4c.ReservedUniformRegister
156		ddlModelBindBy.selection = (if nw4c.VisibilityBindByName then 2 else 1)
157		--
158		spnToleranceNodeT.value = nw4c.ToleranceTrans
159		spnToleranceNodeR.value = nw4c.ToleranceRotate
160		spnToleranceNodeS.value = nw4c.ToleranceScale
161		--
162		spnToleranceTexT.value = nw4c.ToleranceUVTrans
163		spnToleranceTexR.value = nw4c.ToleranceUVRotate
164		spnToleranceTexS.value = nw4c.ToleranceUVScale
165		spnToleranceColor.value = nw4c.ToleranceColor
166		--
167		--spnPrecisionTrans.value = nw4c.PrecisionTrans
168		--spnPrecisionRotate.value = nw4c.PrecisionRotate
169		--spnPrecisionScale.value = nw4c.PrecisionScale
170		--
171		spnScaleQuality.value = nw4c.ScaleQuality
172		spnRotateQuality.value = nw4c.RotateQuality
173		spnTransQuality.value = nw4c.TransQuality
174		--
175		ddlQuantPosition.selection = nw4c.QuantPos
176		ddlQuantNormal.selection = nw4c.QuantNormal
177		ddlQuantTex.selection = nw4c.QuantTex
178		--
179		chkUseFigureMode.state = nw4c.UseFiguremode
180		rdoFrameFormat.state = (if nw4c.IsFrameFormat then 2 else 1)
181		--
182		chkMergeCmdl.state = nw4c.UseMerge
183		editMergeFile.text = nw4c.MergeFilename
184
185		-- �t�@�C�����A�p�X�����̏ꍇ�ɓK���Ȓl������
186		if(editFilepath.text == "") do
187		(
188			-- max�t�@�C�����ǂݍ��݁E�ۑ�����Ă��Ȃ��ꍇ
189			if(maxFilePath == "") then editFilepath.text = (pathConfig.getDir #export)
190			else editFilepath.text = maxFilePath
191		)
192		if(editFilename.text == "") do
193		(
194			-- max�t�@�C�����ǂݍ��݁E�ۑ�����Ă��Ȃ��ꍇ
195			if(maxFilePath == "") then editFilename.text = "nw4c"
196			else editFilename.text = (getFilenameFile maxFileName)
197		)
198		redrawItems()
199	)
200
201	fn saveConfig  saveToScene:true =
202	(
203		--print "save config"
204		local nw4c = nw4cmax
205		nw4c.doesExportSelected = (rdoSelection.state == 2)
206		nw4c.outFolder = editFilepath.text
207		nw4c.filename = editFilename.text
208		nw4c.UseCreativeStudio = chkUseCS.state
209
210		nw4c.doesExportModel = chkExportModel.state
211		nw4c.doesExportTexture = chkExportTex.state
212		nw4c.doesExportAnimation = chkExportSkelAnim.state
213		nw4c.doesExportCamera = chkExportCamera.state
214		nw4c.doesExportLight = chkExportLight.state
215		nw4c.doesExportMtlAnim = chkExportMtlAnim.state
216		nw4c.doesExportModelAnim = chkExportMdlAnim.state
217		nw4c.doesExportEnv = chkExportEnv.state
218		--
219		nw4c.Magnify = spnMagnify.value
220		--
221		nw4c.doesExportAllFrames = (rdoTimeRange.state == 1)
222		nw4c.StartFrame = spnTimeStart.value
223		nw4c.EndFrame = spnTimeEnd.value
224		nw4c.IsLoop = chkAnimationLoop.state
225		nw4c.AnimPrecision = case ddlAnimationPrecision.selection of
226			(
227				1: 1
228				2: 2
229				3: 5
230				4: 10
231				default: 1
232			)
233		--
234		nw4c.CompressNode = ddlCompressNode.selection
235		nw4c.OptimizePrimitive = chkOptimizePrim.state
236		-- nw4c.OptimizeMaterial = chkOptimizeMtl.state
237		nw4c.OptimizeMaterial = (ddlOptimizeMtl.selection	== 2)
238		nw4c.DisableModelSimplification = chkDisableSimplification.state
239		nw4c.NonUniformScale = chkNonUniformScale.state
240		nw4c.ReservedUniformRegister = spnReserveUniform.value
241		nw4c.VisibilityBindByName = (ddlModelBindBy.selection == 2)
242		--
243		nw4c.ToleranceTrans = spnToleranceNodeT.value
244		nw4c.ToleranceRotate = spnToleranceNodeR.value
245		nw4c.ToleranceScale = spnToleranceNodeS.value
246		--
247		nw4c.ToleranceUVTrans = spnToleranceTexT.value
248		nw4c.ToleranceUVRotate = spnToleranceTexR.value
249		nw4c.ToleranceUVScale = spnToleranceTexS.value
250		nw4c.ToleranceColor = spnToleranceColor.value
251		--
252		--nw4c.PrecisionTrans = spnPrecisionTrans.value
253		--nw4c.PrecisionRotate = spnPrecisionRotate.value
254		--nw4c.PrecisionScale = spnPrecisionScale.value
255		--
256		nw4c.QuantPos = ddlQuantPosition.selection
257		nw4c.QuantNormal = ddlQuantNormal.selection
258		nw4c.QuantTex = ddlQuantTex.selection
259		--
260		nw4c.ScaleQuality = spnScaleQuality.value
261		nw4c.RotateQuality = spnRotateQuality.value
262		nw4c.TransQuality = spnTransQuality.value
263		--
264		nw4c.useFiguremode = chkUseFigureMode.state
265		nw4c.IsFrameFormat = (rdoFrameFormat.state == 2)
266		--
267		nw4c.UseMerge = chkMergeCmdl.state
268		nw4c.MergeFilename = editMergeFile.text
269
270		if saveToScene do nw4c.SaveSetting()
271	)
272
273	fn checkOverwriteFiles fName =
274	(
275		local nw4c = nw4cmax
276		local owflag = false
277		if nw4c.doesExportModel and  doesFileExist(fName + ".cmdl") do ( owflag = true)
278		if nw4c.doesExportAnimation and  doesFileExist(fName + ".cskla") do ( owflag = true)
279		if nw4c.doesExportCamera and  doesFileExist(fName + ".ccam") do ( owflag = true)
280		if nw4c.doesExportLight and  doesFileExist(fName + ".clgt") do ( owflag = true)
281		if nw4c.doesExportModelAnim and  doesFileExist(fName + ".cmdla") do ( owflag = true)
282		if nw4c.doesExportMtlAnim and  doesFileExist(fName + ".cmata") do ( owflag = true)
283		if nw4c.doesExportEnv and  doesFileExist(fName + ".cenv") do ( owflag = true)
284
285		if owflag == false do
286		(
287			return true
288		)
289
290		mes = fName + ".*\n" + " already exists.\nOverwrite ?"
291		local ret = queryBox mes title:"confirm overwrite"
292		return ret
293	)
294
295	fn doExport =
296	(
297		local fname = editFilepath.text
298		local nw4c = nw4cMax
299		if(fname[fname.count] != "\\") do append fname "\\"
300		if (chkUseCS.state == false) do
301		(
302			if  (fname.count) <= 1 or not (doesFileExist fname) do
303			(
304				messageBox "Output Folder is wrong"
305				return undefined
306			)
307		)
308		if (editFilename.text.count <= 0)do
309		(
310			messageBox "Output File Name is wrong"
311			return undefined
312		)
313		-- time
314		if (rdoTimeRange.state == 2) do
315		(
316			if(spnTimeStart.value > spnTimeEnd.value) do
317			(
318				messageBox "Time Range is wrong"
319				return undefined
320			)
321		)
322
323		if (spnReserveUniform.value + (if chkNonUniformScale.state then 6 else 3) ) > 60 do
324		(
325			messageBox "Max Reserved Uniform Registers is wrong"
326			return undefined
327		)
328
329		saveConfig saveToScene:utils.enableSaveToScene
330		utils.saveSettingDefault()
331
332		if (chkUseCS.state == false) do
333		(
334			ret = checkOverwriteFiles (fname + editFilename.text)
335			if not ret do
336			(
337				return undefined
338			)
339		)
340
341		displayTempPrompt "Exporting..." 99999999
342		setWaitCursor()
343		local ret = nw4cMax.doExport(rdoSelection.state == 2)
344		setArrowCursor()
345		removeTempPrompt()
346		return ret
347	)
348
349	on btnSelectPath pressed do
350	(
351		local filepath = getSavePath initialDir:editFilepath.text
352		if(filepath != undefined) do editFilepath.text = filepath
353	)
354	on btnNameNode pressed do
355	(
356		sel = getCurrentSelection()
357		if sel.count > 0 do
358		(
359			editFilename.text = sel[1].name
360		)
361	)
362	on btnNameScene pressed do
363	(
364		if(maxFilePath != "") do
365		(
366			editFilename.text = (getFilenameFile maxFileName)
367		)
368	)
369	on btnSelectMerge pressed do
370	(
371		local filepath = getOpenFileName initialDir:editMergeFile.text types:"NW4C Model(*.cmdl)|*.cmdl|All|*.*|"
372		if(filepath != undefined) do editMergeFile.text = filepath
373	)
374
375	on nw4cExportRollout open  do
376	(
377		nw4cExportRollout.utils.loadSettingDefault()
378		loadConfig loadFromScene:utils.enableSaveToScene
379	)
380	on nw4cExportRollout close  do
381	(
382		--print "close nw4cExportRollout"
383		--nw4cExportRollout.utils.saveSettingDefault()
384		--nw4cExportRollout.utils.saveSettingConfig()
385	)
386
387	on btnExport pressed  do
388	(
389		local ret = doExport()
390		if ret == true then
391		(
392			DestroyDialog nw4cExportRollout
393		)
394		else if ret == false then
395		(
396			messageBox "Export Error!"
397		)
398		else if ret == undefined then
399		(
400			-- donothing
401		)
402	)
403	on btnApply pressed  do
404	(
405		local ret = doExport()
406		if ret == false then
407		(
408			messageBox "Export Error!"
409		)
410		else if ret == undefined then
411		(
412			-- donothing
413		)
414	)
415	on btnClose pressed  do DestroyDialog nw4cExportRollout
416	on rdoTimeRange changed val do redrawItems()
417	on chkMergeCmdl changed val do redrawItems()
418	on chkUseCS changed val do redrawItems()
419) -- rollout
420
421-----------------------------------------------------
422-- main menu
423rcMenu NW4CSettingMenu
424(
425	subMenu "NW4C Settings"
426	(
427		menuItem mi_scene "Save / Load Scene Settings" checked:false
428		menuItem mi_resetScene "Reset Scene Settings"
429		menuItem mi_deleteScene "Delete Scene Settings"
430		separator sep1
431		menuItem mi_loadFile "Load Settings from c3es File"
432		menuItem mi_saveFile "Save Settings to c3es File"
433	)
434	fn updateMenu =
435	(
436		mi_scene.checked = nw4cExportRollout.utils.enableSaveToScene
437	)
438	on mi_scene picked do
439	(
440		local val = nw4cExportRollout.utils.enableSaveToScene
441		nw4cExportRollout.utils.enableSaveToScene = not val
442		nw4cExportRollout.utils.saveSettingConfig()
443		updateMenu()
444	)
445	on mi_resetScene picked do
446	(
447		if (queryBox "Reset NW4C Settings?") do
448		(
449			nw4cmax.ResetSetting()
450			nw4cExportRollout.loadConfig loadFromScene:false
451			updateMenu()
452		)
453	)
454	on mi_deleteScene picked do
455	(
456		if (queryBox "Delete NW4C Settings?") do
457		(
458			deleteItem rootnode.custattributes "NW4C Custom Attribute"
459			nw4cExportRollout.loadConfig loadFromScene:false
460			updateMenu()
461		)
462	)
463	on mi_saveFile picked do
464	(
465		--print "mi_saveFile"
466		nw4cExportRollout.saveConfig saveToScene:false
467		local fname = getSaveFileName caption:"Save NW4C Setting File" types:"NW4C Settings(*.c3es)|*.c3es|All|*.*|" historyCategory:"NW4C_Setting_File"
468		if not (nw4cExportRollout.utils.saveSettingToFile fname) do
469		(
470			messageBox "c3es save error"
471		)
472	)
473	on mi_loadFile picked do
474	(
475		--print "mi_loadFile"
476		local fname = getOpenFileName caption:"Load NW4C Setting File" types:"NW4C Settings(*.c3es)|*.c3es|All|*.*|" historyCategory:"NW4C_Setting_File"
477		if not (nw4cExportRollout.utils.loadSettingFromFile fname) do
478		(
479			messageBox "c3es load error"
480		)
481		nw4cExportRollout.loadConfig loadFromScene:false
482	)
483	on NW4CSettingMenu open do updateMenu()
484	on NW4CSettingMenu update do updateMenu()
485)
486
487macroScript nw4cMS_ExportWithSetting category:"NW4C"
488(
489	on execute do
490	(
491		CreateDialog  nw4cExportRollout modal:true menu:NW4CSettingMenu
492	)
493)
494
495macroScript ResetExportSetting category:"NW4C"
496(
497	on execute do
498	(
499		local ret = queryBox "Reset Export Setting?" title:"confirm reset"
500		if ret do
501		(
502			nw4cmax.ResetSetting()
503			nw4cmax.SaveSetting()
504		)
505	)
506)
507
508macroScript nw4cMS_ExportNow category:"NW4C"
509(
510	on execute do
511	(
512		local nw4c = nw4cmax
513		local fromScene = nw4cExportRollout.utils.loadSettingDefault()
514		if fromScene do nw4c.LoadSetting()
515
516		local fname = nw4c.outFolder
517		local nw4c = nw4cMax
518		if(fname[fname.count] != "\\") do append fname "\\"
519
520		if (nw4c.UseCreativeStudio == false) do
521		(
522			if  not (doesFileExist fname) do
523			(
524				messageBox "Output Folder is wrong"
525				return false
526			)
527			ret = nw4cExportRollout.checkOverwriteFiles (fname + nw4c.filename)
528			if not ret do
529			(
530				return false
531			)
532		)
533
534		if (nw4c.filename.count <= 0)do
535		(
536			messageBox "Output File Name is wrong"
537			return false
538		)
539
540		fname = fname + nw4c.filename + ".cmdl"
541
542		displayTempPrompt "Exporting..." 99999999
543		setWaitCursor()
544		local ret = nw4c.doExport nw4c.doesExportSelected
545		setArrowCursor()
546		removeTempPrompt()
547
548		if not ret do
549		(
550			messageBox "Export error!"
551		)
552	)
553)
554
555macroScript nw4cMS_SetNoCompressNode category:"NW4C"
556(
557	on execute do
558	(
559		CreateDialog  nw4cNodeRollout
560	)
561)
562macroScript nw4cMS_SetBillboard category:"NW4C"
563(
564	on execute do
565	(
566		CreateDialog  nw4cBillboardRollout
567	)
568)
569
570macroScript nw4cMS_SetMaterial category:"NW4C"
571(
572	on execute do
573	(
574		CreateDialog  nw4cMaterialRollout
575	)
576)
577
578macroScript nw4cMS_SetRenderPriority category:"NW4C"
579(
580	on execute do
581	(
582		CreateDialog  nw4cRenderPriorityRollout
583	)
584)
585
586macroScript nw4cMS_SetCombineGroup category:"NW4C"
587(
588	on execute do
589	(
590		CreateDialog  nw4cCombineRollout
591	)
592)
593
594
595
596macroScript nw4cMS_PluginVersion category:"NW4C"
597(
598	on execute do
599	(
600		local nw4c = nw4cmax
601		if nw4c == undefined do return()
602		mes = "NintendoWare for CTR\n"
603		mes += "3ds Max Plugin Ver " + nw4c.GetVersionString()
604		mes += "\n"
605		mes += "(C)2010 Nintendo.,Ltd.\n"
606		mes += "All rights reserved"
607
608		messageBox mes title:"NW4C 3ds Max Plugin Version"
609	)
610)
611
612
613fn getNw4cMenu =
614(
615	local mainMenuBar = menuman.getMainMenuBar()
616	for i = 1 to mainMenuBar.numitems() do
617	(
618		local mi = mainMenuBar.getItem i
619		if ( (mi.getTitle()) == "NW4C" ) do
620		(
621			return mi
622		)
623	)
624	-- NW4C���j���[�����o�^
625	local subMenu = menuMan.createMenu "NW4C"
626	local subMenuItem = menuMan.createSubMenuItem "Test Menu" subMenu
627	-- ���C�� ���j���[ �o�[�̍Ōォ�� 2 �Ԗڂ̃��j���[���ڂ̃C���f�b�N�X���v�Z���܂��B
628	local subMenuIndex = mainMenuBar.numItems() - 1
629	-- �T�u���j���[���Ōォ�� 2 �Ԗڂ̃X���b�g�ɒlj����܂��B
630	mainMenuBar.addItem subMenuItem subMenuIndex
631	return subMenuItem
632)
633
634fn resetMenuActions mi =
635(
636	local menu = mi.getSubMenu()
637	-- �܂��o�^�ς݂̃T�u���j���[�A�C�e�����폜
638	while (menu.numItems() > 0) do
639	(
640		menu.removeItemByPosition 1
641	)
642
643	local dialogItem
644
645	dialogItem = menuMan.createActionItem "nw4cMS_ExportNow" "NW4C"
646	dialogItem.setTitle "NW4C Export"
647	dialogItem.setUseCustomTitle true
648	menu.addItem dialogItem -1
649
650	dialogItem = menuMan.createActionItem "nw4cMS_ExportWithSetting" "NW4C"
651	dialogItem.setTitle "NW4C Export With Setting"
652	dialogItem.setUseCustomTitle true
653	menu.addItem dialogItem -1
654
655	dialogItem = menuMan.createSeparatorItem()
656	menu.addItem dialogItem -1
657
658	dialogItem = menuMan.createActionItem "nw4cMS_SetMaterial" "NW4C"
659	dialogItem.setTitle "NW4C Set Material Attribute"
660	dialogItem.setUseCustomTitle true
661	menu.addItem dialogItem -1
662
663	dialogItem = menuMan.createActionItem "nw4cMS_SetRenderPriority" "NW4C"
664	dialogItem.setTitle "NW4C Set Render Priority"
665	dialogItem.setUseCustomTitle true
666	menu.addItem dialogItem -1
667
668	dialogItem = menuMan.createSeparatorItem()
669	menu.addItem dialogItem -1
670
671	dialogItem = menuMan.createActionItem "nw4cMS_SetNoCompressNode" "NW4C"
672	dialogItem.setTitle "NW4C Set No Compress Node"
673	dialogItem.setUseCustomTitle true
674	menu.addItem dialogItem -1
675
676	dialogItem = menuMan.createActionItem "nw4cMS_SetBillboard" "NW4C"
677	dialogItem.setTitle "NW4C Set Billboard"
678	dialogItem.setUseCustomTitle true
679	menu.addItem dialogItem -1
680
681	dialogItem = menuMan.createActionItem "nw4cMS_SetCombineGroup" "NW4C"
682	dialogItem.setTitle "NW4C Set Combine Group"
683	dialogItem.setUseCustomTitle true
684	menu.addItem dialogItem -1
685
686	dialogItem = menuMan.createSeparatorItem()
687	menu.addItem dialogItem -1
688
689	dialogItem = menuMan.createActionItem "nw4cMS_PluginVersion" "NW4C"
690	dialogItem.setTitle "Plugin Version"
691	dialogItem.setUseCustomTitle true
692	menu.addItem dialogItem -1
693
694)
695
696fileIn  "NW4C_node.ms.inc"
697fileIn  "NW4C_mtl.ms.inc"
698
699
700----------------------------------------------
701-- NW4C Main
702
703fn nw4cmain =
704(
705	-- ���C�����j���[��NW4C���j���[��lj�
706	local nw4cMenu = getNw4cMenu()
707	resetMenuActions nw4cMenu
708	-- �}�e���A���G�f�B�^��NW4C���j���[��lj�
709	local nw4cMtlMenu = getNw4cMtlMenu()
710	resetMtlMenuActions nw4cMtlMenu
711
712	nw4cExportRollout.utils.loadSettingDefault()
713
714	menuMan.updateMenuBar()
715
716	--CreateDialog  nw4cExportRollout modal:true
717
718)
719
720-- nw4c�v���O�C�����ǂݍ��܂�Ă��Ȃ��ꍇ�͉������Ȃ��B
721if nw4cmax != undefined do
722(
723	--print "NW4C menu loaded"
724	nw4cMain()
725)
726