-- NW4C Node Tool (2011/02/15) -- Version 1.0.0 -- (c)2010-2011 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 = ( 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 rollout nw4cForceKeyRollout "NW4C Set Force Export Key" width:320 height:450 ( group "Selected Nodes" ( dotNetControl lv_nodes "System.Windows.Forms.ListView" width:288 height:164 ) group "Set" ( checkbox chkExportTrans "Force Export Translate Key" width:280 height:16 offset:[0,-4] checkbox chkExportRotate "Force Export Rotate Key" width:280 height:16 offset:[0,-4] checkbox chkExportScale "Force Export Scale Key" width:280 height:16 offset:[0,-4] checkbox chkExportVisibility "Force Export Visibility Key" width:280 height:16 offset:[0,-4] ) group "Search" ( label lblExportTrans "Force Export Translate Key" align:#left across:4 label lblDummy3 "" checkbox chkS_ExportTransOFF "Off" checkbox chkS_ExportTransON "On" label lblExportRotate "Force Export Rotate Key" align:#left across:4 label lblDummy2 "" checkbox chkS_ExportRotateOFF "Off" checkbox chkS_ExportRotateON "On" label lblExportScale "Force Export Scale Key" align:#left across:4 label lblDummy1 "" checkbox chkS_ExportScaleOFF "Off" checkbox chkS_ExportScaleON "On" label lblExportVis "Force Export Visibility Key" align:#left across:4 label lblDummy4 "" checkbox chkS_ExportVisOFF "Off" checkbox chkS_ExportVisON "On" radioButtons rdoSearchType "" width:98 height:16 labels:#("AND", "OR") columns:2 offset:[0,4] across:2 button btnSearch "Search" width:112 height:24 ) button btnClose "Close" width:304 height:24 local donotRedraw local nodes = #() fn initListView = ( lv_nodes.gridLines = true lv_nodes.View = (dotNetClass "System.Windows.Forms.View").Details lv_nodes.fullRowSelect = true lv_nodes.AutoSize = true lv_nodes.MultiSelect = false lv_nodes.Columns.add "Node Name " lv_nodes.Columns.add "Translate" lv_nodes.Columns.add "Rotate" lv_nodes.Columns.add "Scale" lv_nodes.Columns.add "Visibility" lv_nodes.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending lv_nodes.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 setExportScale n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.exportScaleKey = flag ) fn setExportRotate n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.exportRotateKey = flag ) fn setExportTrans n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.exportTranslateKey = flag ) fn setExportVis n flag = ( local attrib = getNodeAttribute n true if attrib == undefined do return undefined attrib.exportVisibilityKey = flag ) fn getExportScale n = ( local attrib = getNodeAttribute n false if attrib == undefined do return false return attrib.exportScaleKey ) fn getExportRotate n = ( local attrib = getNodeAttribute n false if attrib == undefined do return false return attrib.exportRotateKey ) fn getExportTrans n = ( local attrib = getNodeAttribute n false if attrib == undefined do return false return attrib.exportTranslateKey ) fn getExportVis n = ( local attrib = getNodeAttribute n false if attrib == undefined do return false return attrib.exportVisibilityKey ) fn updateSelection = ( if donotRedraw do return() lv_nodes.Items.Clear() local lvItems =#() local str = "" for n in nodes do ( local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name local sub_li local attr = getNodeAttribute n false if attr != undefined then --アトリビュートがある場合 ( sub_li = li.SubItems.add (attr.exportTranslateKey as string) sub_li = li.SubItems.add (attr.exportRotateKey as string) sub_li = li.SubItems.add (attr.exportScaleKey as string) sub_li = li.SubItems.add (attr.exportVisibilityKey as string) ) else -- アトリビュートがない場合 ( sub_li = li.SubItems.add "false" sub_li = li.SubItems.add "false" sub_li = li.SubItems.add "false" sub_li = li.SubItems.add "false" ) append lvItems li ) lv_nodes.Items.AddRange lvItems if nodes.count > 0 then ( chkExportScale.enabled = true chkExportRotate.enabled = true chkExportTrans.enabled = true chkExportVisibility.enabled = true chkExportScale.checked = getExportScale nodes[1] chkExportRotate.checked = getExportRotate nodes[1] chkExportTrans.checked = getExportTrans nodes[1] chkExportVisibility.checked = getExportVis nodes[1] ) else ( chkExportScale.enabled = false chkExportRotate.enabled = false chkExportTrans.enabled = false chkExportVisibility.enabled = false ) ) on chkExportScale changed v do ( for n in nodes do ( setExportScale n v ) updateSelection() ) on chkExportRotate changed v do ( for n in nodes do ( setExportRotate n v ) updateSelection() ) on chkExportTrans changed v do ( for n in nodes do ( setExportTrans n v ) updateSelection() ) on chkExportVisibility changed v do ( for n in nodes do ( setExportVis n v ) updateSelection() ) fn addCallback = ( callbacks.addScript #selectionSetChanged "nw4cForceKeyRollout.selectionCallback()" \ id:#nw4cForceKeySelectionChange ) fn removeCallback = ( callbacks.removeScripts id:#nw4cForceKeySelectionChange ) fn selectionCallback = ( nodes = #() for n in selection do appendIfUnique nodes n updateSelection() ) on nw4cForceKeyRollout open do ( donotRedraw = false initListView() nodes = #() addCallback() selectionCallback() ) on nw4cForceKeyRollout close do ( removeCallback() ) on btnSearch pressed do ( removeCallback() clearSelection() nodes = #() local bScaleON = chkS_ExportScaleON.checked local bScaleOFF = chkS_ExportScaleOFF.checked local bRotON = chkS_ExportRotateON.checked local bRotOFF = chkS_ExportRotateOFF.checked local bTransON = chkS_ExportTransON.checked local bTransOFF = chkS_ExportTransOFF.checked local bVisON = chkS_ExportVisON.checked local bVisOFF = chkS_ExportVisOFF.checked local scaleKey, rotKey, transKey, visKey local isSearchAnd = if rdoSearchType.state == 1 then true else false local isSearchOr = not isSearchAnd for n in objects do ( local attr = getNodeAttribute n false if attr == undefined then ( scaleKey = rotKey = transKey = visKey = false ) else ( scaleKey = attr.exportScaleKey rotKey = attr.exportRotateKey transKey = attr.exportTranslateKey visKey = attr.exportVisibilityKey ) local compare = true -- 他の条件で比較を続けるかどうか? local ret =false -- このノードが比較条件を満たしたかどうか -- scale if (bScaleON or bScaleOFF) and compare do ( ret = (scaleKey == bScaleON) or ((not scaleKey) == bScaleOFF) if ret and isSearchOr then compare = false else if (not ret) and isSearchAnd do compare = false ) -- rotate if (bRotON or bRotOFF) and compare do ( ret = (rotKey == bRotON) or ((not rotKey) == bRotOFF) if ret and isSearchOr then compare = false else if (not ret) and isSearchAnd do compare = false ) -- translate if (bTransON or bTransOFF) and compare do ( ret = (transKey == bTransON) or ((not transKey) == bTransOFF) if ret and isSearchOr then compare = false else if (not ret) and isSearchAnd do compare = false ) -- visibility if (bVisON or bVisOFF) and compare do ( ret = (visKey == bVisON) or ((not visKey) == bVisOFF) if ret and isSearchOr then compare = false else if (not ret) and isSearchAnd do compare = false ) -- 条件を満たせばノードを配列に追加 if ret do ( appendIfUnique nodes n ) ) for n in nodes do ( selectMore n ) updateSelection() addCallback() ) on btnClose pressed do DestroyDialog nw4cForceKeyRollout )-- Set Force Export Key rollout rollout nw4cNodeUserDataRollout "NW4C Set User Data" width:480 height:290 ( group "Selected Node" ( label lblNode --dotNetControl lv_nodes "System.Windows.Forms.ListView" width:288 height:164 ) group "Edit Data" ( button btnUp "Move Up" across:5 button btnDown "Move Down" button btnAdd "Add..." button btnDelete "Delete" button btnEdit "Edit..." dotNetControl lv_data "System.Windows.Forms.ListView" width:450 height:164 ) button btnClose "Close" width:474 height:24 local utils = nw4c_utils() local donotRedraw local nodes = #() local dataset = undefined 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 initListView = ( lv_data.gridLines = true lv_data.View = (dotNetClass "System.Windows.Forms.View").Details lv_data.fullRowSelect = true lv_data.AutoSize = true lv_data.MultiSelect = false lv_data.Columns.add " Name " lv_data.Columns.add " Type " lv_data.Columns.add " Size" lv_data.Columns.add " Value" --lv_data.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending lv_data.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) ) fn saveData = ( -- 1つだけ選択されたときだけ処理する if nodes.count != 1 do return() local n = nodes[1] local attr = getNodeAttribute n true if attr != undefined do ( attr.userSettings = dataset.toString() ) ) fn updateSelection = ( if donotRedraw do return() lv_data.Items.Clear() dataset = nw4c_userDataSet() local lvItems =#() -- 1つだけ選択されたときだけ処理する if nodes.count == 1 then ( lblNode.text = nodes[1].name btnUp.enabled = true btnDown.enabled = true btnAdd.enabled = true btnDelete.enabled = true btnEdit.enabled = true ) else ( lblNode.text = "" btnUp.enabled = false btnDown.enabled = false btnAdd.enabled = false btnDelete.enabled = false btnEdit.enabled = false return () ) local n = nodes[1] local attr = getNodeAttribute n false if attr != undefined then --アトリビュートがある場合 ( local str = attr.userSettings if (classof str) == String do ( local ret = dataset.fromString str if ret do ( for i = 1 to dataset.list.count do ( local data = dataset.list[i] local li = dotNetObject "System.Windows.Forms.ListViewItem" data.dataname local sub_li sub_li = li.SubItems.add (data.type as String) sub_li = li.SubItems.add ((data.valueCount()) as string) sub_li = li.SubItems.add ((data.valueToString oneline:true) as string) append lvItems li ) ) ) ) else -- アトリビュートがない場合 ( ) lv_data.Items.AddRange lvItems ) fn addCallback = ( callbacks.addScript #selectionSetChanged "nw4cNodeUserDataRollout.selectionCallback()" \ id:#nw4cNodeUserDataSelectionChange ) fn removeCallback = ( callbacks.removeScripts id:#nw4cNodeUserDataSelectionChange ) fn selectionCallback = ( nodes = #() for n in selection do appendIfUnique nodes n updateSelection() ) fn EditData data add = ( nw4cEditUserDataRollout_ValueSet = dataset nw4cEditUserDataRollout_Value = data CreateDialog nw4cEditUserDataRollout modal:true if nw4cEditUserDataRollout_Value != undefined do ( if add do dataset.appendData nw4cEditUserDataRollout_Value saveData() updateSelection() ) ) on nw4cNodeUserDataRollout open do ( donotRedraw = false initListView() nodes = #() addCallback() selectionCallback() ) on nw4cNodeUserDataRollout close do ( removeCallback() ) on btnUp pressed do ( if lv_data.SelectedIndices.Count > 0 do ( local id = lv_data.SelectedIndices.Item[0] local maxid = id + 1 if id > 0 do ( local tmp = dataset.list[maxid] deleteItem dataset.list (maxid) insertItem tmp dataset.list (maxid - 1) saveData() updateSelection() lv_data.Items.Item[id-1].Selected = true ) lv_data.Focus() ) ) on btnDown pressed do ( if lv_data.SelectedIndices.Count > 0 do ( local id = lv_data.SelectedIndices.Item[0] local maxid = id + 1 if maxid < dataset.list.count do ( local tmp = dataset.list[maxid] deleteItem dataset.list (maxid) insertItem tmp dataset.list (maxid + 1) saveData() updateSelection() lv_data.Items.Item[id+1].Selected = true ) lv_data.Focus() ) ) on btnDelete pressed do ( if lv_data.SelectedIndices.Count > 0 do ( local id = lv_data.SelectedIndices.Item[0] local maxid = id + 1 ( deleteItem dataset.list (maxid) saveData() updateSelection() ) lv_data.Focus() ) ) on btnAdd pressed do ( if (classof dataset) == nw4c_userDataSet do ( editData (nw4c_userData()) true ) ) on btnEdit pressed do ( if (classof dataset) == nw4c_userDataSet do ( if lv_data.SelectedIndices.Count > 0 do ( local id = lv_data.SelectedIndices.Item[0] local maxid = id + 1 editData (dataset.list[maxid]) false ) ) ) on btnClose pressed do DestroyDialog nw4cNodeUserDataRollout )-- Set User Data