-- NW4C Material Tool(2010/09/02) -- Version 0.4.3 -- (c)2010 Nintendo rollout nw4cNodeRollout "NW4C Set No Compress Node" width:320 height:348 ( groupBox grp1 "Selected Nodes" pos:[8,8] width:304 height:188 --label lblSelectedNode "" pos:[16,24] width:288 height:64 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 groupBox grp2 "Set" pos:[8,204] width:304 height:48 dropDownList ddlSetCompress "" pos:[16,220] width:200 height:22 items:#("Compress this node if possible","Don't compress this node") groupBox grp3 "Search" pos:[8,260] width:304 height:52 radioButtons rdoSearch "" pos:[16,276] width:208 height:16 labels:#("Compress If Possible", "Don't Compress") columns:1 button btnSearch "Search" pos:[226,284] width:80 height:24 button btnClose "Close" pos:[8,320] width:304 height:24 local donotRedraw local nodes = #() fn initListView = ( lv_mtl.gridLines = true lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details lv_mtl.fullRowSelect = true lv_mtl.AutoSize = true lv_mtl.MultiSelect = false lv_mtl.Columns.add "Node Name " lv_mtl.Columns.add "Compress" lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) ) fn getNodeAttribute n create = ( local attrib = n.custAttributes["NW4C Node Custom Attribute"] if attrib == undefined then ( if not create do return undefined attrib = nw4c_node_custom_attribute() append n.custAttributes attrib ) return attrib ) fn setNodeNoCompress n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.noCompress = flag ) fn getNodeNoCompress n = ( local attrib = getNodeAttribute n false if attrib == undefined do return false return attrib.noCompress ) fn updateSelection = ( if donotRedraw do return() lv_mtl.Items.Clear() local lvItems =#() local str = "" for n in nodes do ( local flag = getNodeNoCompress n local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name local sub_li str = case flag of ( true: "Don't compress" default: "If possible" ) sub_li = li.SubItems.add str append lvItems li ) lv_mtl.Items.AddRange lvItems if nodes.count > 0 then ( ddlSetCompress.enabled = true ddlSetCompress.selection = case getNodeNoCompress nodes[1] of ( true: 2 false: 1 ) ) else ( ddlSetCompress.enabled = false ) ) on ddlSetCompress selected i do ( local v = case i of ( 1: false 2: true ) for n in nodes do ( setNodeNoCompress n v ) updateSelection() ) fn selectionCallback = ( nodes = #() for n in selection do appendIfUnique nodes n updateSelection() ) on nw4cNodeRollout open do ( donotRedraw = false initListView() nodes = #() callbacks.addScript #selectionSetChanged "nw4cNodeRollout.selectionCallback()" id:#nw4cNodeSelectionChange selectionCallback() ) on nw4cNodeRollout close do ( callbacks.removeScripts id:#nw4cNodeSelectionChange ) on btnSearch pressed do ( donotRedraw = true clearSelection() nodes = #() local flag = (rdoSearch.state == 2) for n in objects do ( if (getNodeNoCompress n) == flag do ( selectMore n appendIfUnique nodes n ) ) donotRedraw = false updateSelection() ) on btnClose pressed do DestroyDialog nw4cNodeRollout )-- node rollout rollout nw4cBillboardRollout "NW4C Set Billboard" width:320 height:400 ( groupBox grp1 "Selected Nodes" pos:[8,8] width:304 height:188 --label lblSelectedNode "" pos:[16,24] width:288 height:64 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 groupBox grp2 "Set" pos:[8,204] width:304 height:48 dropDownList ddlSetBillboard "" pos:[16,220] width:200 height:22 \ items:#("Off","World","World Viewpoint","Screen","Screen Viewpoint","Y Axial","Y Axial Viewpoint") groupBox grp3 "Search" pos:[8,260] width:304 height:100 --radioButtons rdoSearch "" pos:[16,276] width:208 height:16 labels:#("Compress If Possible", "Don't Compress") columns:1 checkbox chkWorld "World" pos:[16,276] width:80 height:16 checkbox chkWorldView "World Viewpoint" pos:[100,276] width:120 height:16 checkbox chkScreen "Screen" pos:[16,294] width:80 height:16 checkbox chkScreenView "Screen Viewpoint" pos:[100,294] width:120 height:16 checkbox chkYAxial "Y Axial" pos:[16,312] width:80 height:16 checkbox chkYAxialView "Y Axial Viewpoint" pos:[100,312] width:120 height:16 button btnSearch "Search" pos:[226,284] width:80 height:24 button btnClose "Close" pos:[8,370] width:304 height:24 local donotRedraw local nodes = #() fn initListView = ( lv_mtl.gridLines = true lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details lv_mtl.fullRowSelect = true lv_mtl.AutoSize = true lv_mtl.MultiSelect = false lv_mtl.Columns.add "Node Name " lv_mtl.Columns.add "Billboard Type" lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) ) fn getNodeAttribute n create = ( local attrib = n.custAttributes["NW4C Node Custom Attribute"] if attrib == undefined then ( if not create do return undefined attrib = nw4c_node_custom_attribute() append n.custAttributes attrib ) return attrib ) fn setNodeBillboardType n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.billboardType = flag ) fn getNodeBillboardType n = ( local attrib = getNodeAttribute n false if attrib == undefined do return 0 return attrib.billboardType ) fn updateSelection = ( if donotRedraw do return() lv_mtl.Items.Clear() local lvItems =#() local str = "" for n in nodes do ( local type = getNodeBillboardType n local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name local sub_li str = case type of ( 1: "World" 2: "World Viewpoint" 3: "Screen" 4: "Screen Viewpoint" 5: "Y Axial" 6: "Y Axial Viewpoint" default: "Off" ) sub_li = li.SubItems.add str append lvItems li ) lv_mtl.Items.AddRange lvItems if nodes.count > 0 then ( ddlSetBillboard.enabled = true ddlSetBillboard.selection = getNodeBillboardType nodes[1] + 1 ) else ( ddlSetBillboard.enabled = false ) ) on ddlSetBillboard selected i do ( local v = i - 1 for n in nodes do ( setNodeBillboardType n v ) updateSelection() ) fn selectionCallback = ( nodes = #() for n in selection do appendIfUnique nodes n updateSelection() ) on nw4cBillboardRollout open do ( donotRedraw = false initListView() nodes = #() for n in selection do appendIfUnique nodes n callbacks.addScript #selectionSetChanged "nw4cBillboardRollout.selectionCallback()" id:#nw4cBillboardSelectionChange updateSelection() ) on nw4cBillboardRollout close do ( callbacks.removeScripts id:#nw4cBillboardSelectionChange ) on btnSearch pressed do ( donotRedraw = true clearSelection() nodes = #() for n in objects do ( local flag = case (getNodeBillboardType n) of ( 1: chkWorld.checked--"World" 2: chkWorldView.checked --"World Viewpoint" 3: chkScreen.checked --"Screen" 4: chkScreenView.checked --"Screen Viewpoint" 5: chkYAxial.checked --"Y Axial" 6: chkYAxialView.checked --"Y Axial Viewpoint" default: false --"Off" ) if flag do ( selectMore n appendIfUnique nodes n ) ) donotRedraw = false updateSelection() ) on btnClose pressed do DestroyDialog nw4cBillboardRollout on lv_mtl SelectedIndexChanged e do ( local numItems = lv_mtl.Items.Count for i = 0 to (numItems - 1) do ( lv_mtl.Items.Item[i].Selected = false ) ) )-- billboard rollout rollout nw4cCombineRollout "NW4C Set Combine Group" width:320 height:386 ( groupBox grp1 "Selected Node" pos:[8,8] width:304 height:188 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 groupBox grp2 "Set" pos:[8,204] width:304 height:64 label lbl6 "Combine Group:" pos:[16,220] width:104 height:16 radioButtons rdoSetCombineType "" pos:[100,220] width:87 height:32 labels:#("Don't care", "") columns:1 default:1 spinner spnSetCombine "" pos:[124,236] width:56 height:16 range:[0,255,0] type:#integer scale:1 enabled:false button btnSequential "Set Sequential" pos:[188,236] width:112 height:24 groupBox grp3 "Search" pos:[8,276] width:304 height:80 label lbl8 "Combine Group:" pos:[16,292] width:104 height:16 radioButtons rdoSearchCombineType "" pos:[100,292] width:89 height:48 labels:#("Don't care", "Condition") columns:1 default:1 \ dropDownList ddlSearchConditionType "" pos:[180,304] width:80 height:22 default:1 \ --enabled:false \ items:#("< : under", "<= : below", "= : exactly", ">= : above", "> : over") spinner spnSearchCombine "" pos:[260,306] width:48 height:16 range:[0,255,0] type:#integer scale:1 --enabled:false button btnSearch "Search" pos:[180,328] width:112 height:24 button btnClose "Close" pos:[8,360] width:304 height:24 local donotRedraw local nodes = #() fn initListView = ( lv_mtl.gridLines = true lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details lv_mtl.fullRowSelect = true lv_mtl.AutoSize = true lv_mtl.MultiSelect = false lv_mtl.Columns.add "Node Name " lv_mtl.Columns.add "Combine Group" lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) ) fn getNodeAttribute n create = ( local attrib = n.custAttributes["NW4C Node Custom Attribute"] if attrib == undefined then ( if not create do return undefined attrib = nw4c_node_custom_attribute() append n.custAttributes attrib ) return attrib ) fn setNodeCombineGroup n id = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.combineGroup = id ) fn getNodeCombineGroup n = ( local attrib = getNodeAttribute n false if attrib == undefined do return -1 return attrib.combineGroup ) fn updateSelection = ( print "updateSelection" if donotRedraw do return() lv_mtl.Items.Clear() local lvItems =#() local str = "" for n in nodes do ( local id = getNodeCombineGroup n local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name local sub_li str = if (id < 0) then "Don't care" else str = (id as string) sub_li = li.SubItems.add str append lvItems li ) lv_mtl.Items.AddRange lvItems if nodes.count > 0 then ( id = getNodeCombineGroup nodes[1] print nodes if (id < 0) then ( rdoSetCombineType.state = 1 spnSetCombine.enabled = false ) else ( rdoSetCombineType.state = 2 spnSetCombine.enabled = true spnSetCombine.value = id ) ) ) fn setNodesAttribute = ( --local mtls = getSelMtls selection local attr undo "Edit Combine Group" on ( spnSetCombine.enabled = (rdoSetCombineType.state == 2) for n in nodes do ( attr = getNodeAttribute n true local val = 0 if rdoSetCombineType.state == 1 then ( attr.combineGroup = -1 ) else ( attr.combineGroup = spnSetCombine.value ) ) ) updateSelection() ) fn nodeNameCompare v1 v2 = ( if (v1.name > v2.name) then 1 else -1 ) fn addCallback = ( callbacks.addScript #selectionSetChanged "nw4cCombineRollout.selectionCallback()" \ id:#nw4cCombineSelectionChange ) fn removeCallback = ( callbacks.removeScripts id:#nw4cCombineSelectionChange ) fn selectionCallback = ( print "selectionCallback" nodes = #() for n in selection do appendIfUnique nodes n qsort nodes nodeNameCompare updateSelection() ) fn sequenceCompare v1 v2 = ( local ret = 0 if(v1[1] > v2[1]) then ( ret = 1 ) else if (v1[1] < v2[1]) then ( ret = -1 ) else ( ret = if (v1[2].name > v2[2].name) then 1 else -1 ) ret ) on btnSequential pressed do ( local seqnodes = #() local id = spnSetCombine.value -- グループIDが255を超える場合はエラー if (id + nodes.count - 1) > 255 then ( messageBox "Combine Group will be greater than 255" return() ) for n in nodes do ( local depth = 0 local p = n do ( depth += 1 p = p.parent ) while (p != undefined) append seqnodes #(depth, n) ) qsort seqnodes sequenceCompare print seqnodes for a in seqnodes do ( setNodeCombineGroup a[2] id id += 1 ) updateSelection() ) on btnSearch pressed do ( removeCallback() clearSelection() nodes = #() for n in objects do ( --local attr = getNodeAttribute n false local id = getNodeCombineGroup n local ret= false case rdoSearchCombineType.state of ( 1: ( -- Don't care if id < 0 do ( ret = true ) ) 2: ( -- condition if id >=0 do ( local v = spnSearchCombine.value case ddlSearchConditionType.selection of ( 1: ( -- under ret = (id < v) ) 2: ( -- below ret = (id <= v) ) 3: ( -- exactly ret = (id == v) ) 4: ( -- above ret = (id >= v) ) 5: ( -- over ret = (id > v) ) ) ) ) default: ret = false ) -- 条件を満たせばマテリアルを配列に追加 if ret do ( appendIfUnique nodes n ) ) for n in nodes do ( selectMore n ) updateSelection() addCallback() ) on rdoSetCombineType changed i do setNodesAttribute() on spnSetCombine changed i do setNodesAttribute() on nw4cCombineRollout open do ( donotRedraw = false initListView() nodes = #() addCallback() selectionCallback() ) on nw4cCombineRollout close do ( removeCallback() ) on btnClose pressed do DestroyDialog nw4cCombineRollout )-- combine rollout