1-- NW4C Material Tool(2010/09/02) 2-- Version 0.4.3 3-- (c)2010 Nintendo 4 5rollout nw4cNodeRollout "NW4C Set No Compress Node" width:320 height:348 6( 7 groupBox grp1 "Selected Nodes" pos:[8,8] width:304 height:188 8 --label lblSelectedNode "" pos:[16,24] width:288 height:64 9 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 10 groupBox grp2 "Set" pos:[8,204] width:304 height:48 11 dropDownList ddlSetCompress "" pos:[16,220] width:200 height:22 items:#("Compress this node if possible","Don't compress this node") 12 groupBox grp3 "Search" pos:[8,260] width:304 height:52 13 radioButtons rdoSearch "" pos:[16,276] width:208 height:16 labels:#("Compress If Possible", "Don't Compress") columns:1 14 button btnSearch "Search" pos:[226,284] width:80 height:24 15 button btnClose "Close" pos:[8,320] width:304 height:24 16 17 local donotRedraw 18 local nodes = #() 19 20 fn initListView = 21 ( 22 lv_mtl.gridLines = true 23 lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details 24 lv_mtl.fullRowSelect = true 25 lv_mtl.AutoSize = true 26 lv_mtl.MultiSelect = false 27 lv_mtl.Columns.add "Node Name " 28 lv_mtl.Columns.add "Compress" 29 lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending 30 lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) 31 ) 32 33 fn getNodeAttribute n create = 34 ( 35 local attrib = n.custAttributes["NW4C Node Custom Attribute"] 36 if attrib == undefined then 37 ( 38 if not create do return undefined 39 attrib = nw4c_node_custom_attribute() 40 append n.custAttributes attrib 41 ) 42 return attrib 43 ) 44 45 fn setNodeNoCompress n flag = 46 ( 47 local attrib = getNodeAttribute n true 48 if attrib == undefined do return undefined 49 attrib.noCompress = flag 50 ) 51 52 fn getNodeNoCompress n = 53 ( 54 local attrib = getNodeAttribute n false 55 if attrib == undefined do return false 56 return attrib.noCompress 57 ) 58 59 fn updateSelection = 60 ( 61 if donotRedraw do return() 62 lv_mtl.Items.Clear() 63 local lvItems =#() 64 65 local str = "" 66 for n in nodes do 67 ( 68 local flag = getNodeNoCompress n 69 70 local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name 71 local sub_li 72 73 str = case flag of 74 ( 75 true: "Don't compress" 76 default: "If possible" 77 ) 78 sub_li = li.SubItems.add str 79 append lvItems li 80 ) 81 lv_mtl.Items.AddRange lvItems 82 83 if nodes.count > 0 then 84 ( 85 ddlSetCompress.enabled = true 86 ddlSetCompress.selection = case getNodeNoCompress nodes[1] of 87 ( 88 true: 2 89 false: 1 90 ) 91 ) 92 else 93 ( 94 ddlSetCompress.enabled = false 95 ) 96 ) 97 98 99 on ddlSetCompress selected i do 100 ( 101 local v = case i of 102 ( 103 1: false 104 2: true 105 ) 106 for n in nodes do 107 ( 108 setNodeNoCompress n v 109 ) 110 updateSelection() 111 ) 112 113 fn selectionCallback = 114 ( 115 nodes = #() 116 for n in selection do appendIfUnique nodes n 117 updateSelection() 118 ) 119 120 on nw4cNodeRollout open do 121 ( 122 donotRedraw = false 123 initListView() 124 nodes = #() 125 callbacks.addScript #selectionSetChanged "nw4cNodeRollout.selectionCallback()" id:#nw4cNodeSelectionChange 126 selectionCallback() 127 ) 128 on nw4cNodeRollout close do 129 ( 130 callbacks.removeScripts id:#nw4cNodeSelectionChange 131 ) 132 on btnSearch pressed do 133 ( 134 donotRedraw = true 135 clearSelection() 136 nodes = #() 137 local flag = (rdoSearch.state == 2) 138 for n in objects do 139 ( 140 if (getNodeNoCompress n) == flag do 141 ( 142 selectMore n 143 appendIfUnique nodes n 144 ) 145 ) 146 donotRedraw = false 147 updateSelection() 148 ) 149 on btnClose pressed do DestroyDialog nw4cNodeRollout 150)-- node rollout 151 152rollout nw4cBillboardRollout "NW4C Set Billboard" width:320 height:400 153( 154 groupBox grp1 "Selected Nodes" pos:[8,8] width:304 height:188 155 --label lblSelectedNode "" pos:[16,24] width:288 height:64 156 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 157 groupBox grp2 "Set" pos:[8,204] width:304 height:48 158 dropDownList ddlSetBillboard "" pos:[16,220] width:200 height:22 \ 159 items:#("Off","World","World Viewpoint","Screen","Screen Viewpoint","Y Axial","Y Axial Viewpoint") 160 groupBox grp3 "Search" pos:[8,260] width:304 height:100 161 --radioButtons rdoSearch "" pos:[16,276] width:208 height:16 labels:#("Compress If Possible", "Don't Compress") columns:1 162 checkbox chkWorld "World" pos:[16,276] width:80 height:16 163 checkbox chkWorldView "World Viewpoint" pos:[100,276] width:120 height:16 164 checkbox chkScreen "Screen" pos:[16,294] width:80 height:16 165 checkbox chkScreenView "Screen Viewpoint" pos:[100,294] width:120 height:16 166 checkbox chkYAxial "Y Axial" pos:[16,312] width:80 height:16 167 checkbox chkYAxialView "Y Axial Viewpoint" pos:[100,312] width:120 height:16 168 169 button btnSearch "Search" pos:[226,284] width:80 height:24 170 button btnClose "Close" pos:[8,370] width:304 height:24 171 172 local donotRedraw 173 local nodes = #() 174 175 fn initListView = 176 ( 177 lv_mtl.gridLines = true 178 lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details 179 lv_mtl.fullRowSelect = true 180 lv_mtl.AutoSize = true 181 lv_mtl.MultiSelect = false 182 lv_mtl.Columns.add "Node Name " 183 lv_mtl.Columns.add "Billboard Type" 184 lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending 185 lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) 186 ) 187 188 fn getNodeAttribute n create = 189 ( 190 local attrib = n.custAttributes["NW4C Node Custom Attribute"] 191 if attrib == undefined then 192 ( 193 if not create do return undefined 194 attrib = nw4c_node_custom_attribute() 195 append n.custAttributes attrib 196 ) 197 return attrib 198 ) 199 200 fn setNodeBillboardType n flag = 201 ( 202 local attrib = getNodeAttribute n true 203 if attrib == undefined do return undefined 204 attrib.billboardType = flag 205 ) 206 207 fn getNodeBillboardType n = 208 ( 209 local attrib = getNodeAttribute n false 210 if attrib == undefined do return 0 211 return attrib.billboardType 212 ) 213 214 fn updateSelection = 215 ( 216 if donotRedraw do return() 217 lv_mtl.Items.Clear() 218 local lvItems =#() 219 220 local str = "" 221 for n in nodes do 222 ( 223 local type = getNodeBillboardType n 224 225 local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name 226 local sub_li 227 228 str = case type of 229 ( 230 1: "World" 231 2: "World Viewpoint" 232 3: "Screen" 233 4: "Screen Viewpoint" 234 5: "Y Axial" 235 6: "Y Axial Viewpoint" 236 default: "Off" 237 ) 238 sub_li = li.SubItems.add str 239 append lvItems li 240 ) 241 lv_mtl.Items.AddRange lvItems 242 243 if nodes.count > 0 then 244 ( 245 ddlSetBillboard.enabled = true 246 ddlSetBillboard.selection = getNodeBillboardType nodes[1] + 1 247 ) 248 else 249 ( 250 ddlSetBillboard.enabled = false 251 ) 252 ) 253 254 on ddlSetBillboard selected i do 255 ( 256 local v = i - 1 257 for n in nodes do 258 ( 259 setNodeBillboardType n v 260 ) 261 updateSelection() 262 ) 263 264 fn selectionCallback = 265 ( 266 nodes = #() 267 for n in selection do appendIfUnique nodes n 268 updateSelection() 269 ) 270 271 on nw4cBillboardRollout open do 272 ( 273 donotRedraw = false 274 initListView() 275 nodes = #() 276 for n in selection do appendIfUnique nodes n 277 callbacks.addScript #selectionSetChanged "nw4cBillboardRollout.selectionCallback()" id:#nw4cBillboardSelectionChange 278 updateSelection() 279 ) 280 on nw4cBillboardRollout close do 281 ( 282 callbacks.removeScripts id:#nw4cBillboardSelectionChange 283 ) 284 on btnSearch pressed do 285 ( 286 donotRedraw = true 287 clearSelection() 288 nodes = #() 289 for n in objects do 290 ( 291 local flag = case (getNodeBillboardType n) of 292 ( 293 1: chkWorld.checked--"World" 294 2: chkWorldView.checked --"World Viewpoint" 295 3: chkScreen.checked --"Screen" 296 4: chkScreenView.checked --"Screen Viewpoint" 297 5: chkYAxial.checked --"Y Axial" 298 6: chkYAxialView.checked --"Y Axial Viewpoint" 299 default: false --"Off" 300 ) 301 if flag do 302 ( 303 selectMore n 304 appendIfUnique nodes n 305 ) 306 ) 307 donotRedraw = false 308 updateSelection() 309 ) 310 on btnClose pressed do DestroyDialog nw4cBillboardRollout 311 on lv_mtl SelectedIndexChanged e do 312 ( 313 local numItems = lv_mtl.Items.Count 314 for i = 0 to (numItems - 1) do 315 ( 316 lv_mtl.Items.Item[i].Selected = false 317 ) 318 ) 319)-- billboard rollout 320 321rollout nw4cCombineRollout "NW4C Set Combine Group" width:320 height:386 322( 323 324 groupBox grp1 "Selected Node" pos:[8,8] width:304 height:188 325 dotNetControl lv_mtl "System.Windows.Forms.ListView" pos:[16,24] width:288 height:164 326 groupBox grp2 "Set" pos:[8,204] width:304 height:64 327 label lbl6 "Combine Group:" pos:[16,220] width:104 height:16 328 radioButtons rdoSetCombineType "" pos:[100,220] width:87 height:32 labels:#("Don't care", "") columns:1 default:1 329 spinner spnSetCombine "" pos:[124,236] width:56 height:16 range:[0,255,0] type:#integer scale:1 enabled:false 330 button btnSequential "Set Sequential" pos:[188,236] width:112 height:24 331 332 groupBox grp3 "Search" pos:[8,276] width:304 height:80 333 label lbl8 "Combine Group:" pos:[16,292] width:104 height:16 334 radioButtons rdoSearchCombineType "" pos:[100,292] width:89 height:48 335 labels:#("Don't care", "Condition") columns:1 default:1 \ 336 dropDownList ddlSearchConditionType "" pos:[180,304] width:80 height:22 default:1 \ --enabled:false \ 337 items:#("< : under", "<= : below", "= : exactly", ">= : above", "> : over") 338 spinner spnSearchCombine "" pos:[260,306] width:48 height:16 range:[0,255,0] type:#integer scale:1 --enabled:false 339 button btnSearch "Search" pos:[180,328] width:112 height:24 340 341 button btnClose "Close" pos:[8,360] width:304 height:24 342 343 local donotRedraw 344 local nodes = #() 345 fn initListView = 346 ( 347 lv_mtl.gridLines = true 348 lv_mtl.View = (dotNetClass "System.Windows.Forms.View").Details 349 lv_mtl.fullRowSelect = true 350 lv_mtl.AutoSize = true 351 lv_mtl.MultiSelect = false 352 lv_mtl.Columns.add "Node Name " 353 lv_mtl.Columns.add "Combine Group" 354 lv_mtl.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending 355 lv_mtl.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) 356 ) 357 358 fn getNodeAttribute n create = 359 ( 360 local attrib = n.custAttributes["NW4C Node Custom Attribute"] 361 if attrib == undefined then 362 ( 363 if not create do return undefined 364 attrib = nw4c_node_custom_attribute() 365 append n.custAttributes attrib 366 ) 367 return attrib 368 ) 369 370 fn setNodeCombineGroup n id = 371 ( 372 local attrib = getNodeAttribute n true 373 if attrib == undefined do return undefined 374 attrib.combineGroup = id 375 ) 376 377 fn getNodeCombineGroup n = 378 ( 379 local attrib = getNodeAttribute n false 380 if attrib == undefined do return -1 381 return attrib.combineGroup 382 ) 383 384 fn updateSelection = 385 ( 386 print "updateSelection" 387 if donotRedraw do return() 388 lv_mtl.Items.Clear() 389 local lvItems =#() 390 391 local str = "" 392 for n in nodes do 393 ( 394 local id = getNodeCombineGroup n 395 396 local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name 397 local sub_li 398 399 str = if (id < 0) then "Don't care" 400 else str = (id as string) 401 sub_li = li.SubItems.add str 402 append lvItems li 403 ) 404 lv_mtl.Items.AddRange lvItems 405 406 if nodes.count > 0 then 407 ( 408 id = getNodeCombineGroup nodes[1] 409 print nodes 410 if (id < 0) then 411 ( 412 rdoSetCombineType.state = 1 413 spnSetCombine.enabled = false 414 ) 415 else 416 ( 417 rdoSetCombineType.state = 2 418 spnSetCombine.enabled = true 419 spnSetCombine.value = id 420 ) 421 ) 422 ) 423 424 fn setNodesAttribute = 425 ( 426 --local mtls = getSelMtls selection 427 local attr 428 undo "Edit Combine Group" on 429 ( 430 spnSetCombine.enabled = (rdoSetCombineType.state == 2) 431 for n in nodes do 432 ( 433 attr = getNodeAttribute n true 434 local val = 0 435 if rdoSetCombineType.state == 1 then 436 ( 437 attr.combineGroup = -1 438 ) 439 else 440 ( 441 attr.combineGroup = spnSetCombine.value 442 ) 443 ) 444 ) 445 updateSelection() 446 ) 447 448 fn nodeNameCompare v1 v2 = 449 ( 450 if (v1.name > v2.name) then 1 else -1 451 ) 452 453 fn addCallback = 454 ( 455 callbacks.addScript #selectionSetChanged "nw4cCombineRollout.selectionCallback()" \ 456 id:#nw4cCombineSelectionChange 457 ) 458 fn removeCallback = 459 ( 460 callbacks.removeScripts id:#nw4cCombineSelectionChange 461 ) 462 463 fn selectionCallback = 464 ( 465 print "selectionCallback" 466 nodes = #() 467 for n in selection do appendIfUnique nodes n 468 qsort nodes nodeNameCompare 469 updateSelection() 470 ) 471 472 fn sequenceCompare v1 v2 = 473 ( 474 local ret = 0 475 if(v1[1] > v2[1]) then 476 ( 477 ret = 1 478 ) 479 else if (v1[1] < v2[1]) then 480 ( 481 ret = -1 482 ) 483 else 484 ( 485 ret = if (v1[2].name > v2[2].name) then 1 else -1 486 ) 487 ret 488 ) 489 490 on btnSequential pressed do 491 ( 492 local seqnodes = #() 493 local id = spnSetCombine.value 494 -- �O���[�vID��255����ꍇ�̓G���[ 495 if (id + nodes.count - 1) > 255 then 496 ( 497 messageBox "Combine Group will be greater than 255" 498 return() 499 ) 500 501 for n in nodes do 502 ( 503 local depth = 0 504 local p = n 505 do 506 ( 507 depth += 1 508 p = p.parent 509 ) 510 while (p != undefined) 511 append seqnodes #(depth, n) 512 ) 513 qsort seqnodes sequenceCompare 514 print seqnodes 515 for a in seqnodes do 516 ( 517 setNodeCombineGroup a[2] id 518 id += 1 519 ) 520 updateSelection() 521 ) 522 523 on btnSearch pressed do 524 ( 525 removeCallback() 526 clearSelection() 527 nodes = #() 528 for n in objects do 529 ( 530 --local attr = getNodeAttribute n false 531 local id = getNodeCombineGroup n 532 local ret= false 533 534 case rdoSearchCombineType.state of 535 ( 536 1: ( -- Don't care 537 if id < 0 do 538 ( 539 ret = true 540 ) 541 ) 542 2: ( -- condition 543 if id >=0 do 544 ( 545 local v = spnSearchCombine.value 546 case ddlSearchConditionType.selection of 547 ( 548 1: ( -- under 549 ret = (id < v) 550 ) 551 2: ( -- below 552 ret = (id <= v) 553 ) 554 3: ( -- exactly 555 ret = (id == v) 556 ) 557 4: ( -- above 558 ret = (id >= v) 559 ) 560 5: ( -- over 561 ret = (id > v) 562 ) 563 ) 564 ) 565 ) 566 default: ret = false 567 ) 568 569 -- ���������}�e���A����z��ɒlj� 570 if ret do 571 ( 572 appendIfUnique nodes n 573 ) 574 ) 575 576 for n in nodes do 577 ( 578 selectMore n 579 ) 580 581 updateSelection() 582 addCallback() 583 ) 584 585 on rdoSetCombineType changed i do setNodesAttribute() 586 on spnSetCombine changed i do setNodesAttribute() 587 588 on nw4cCombineRollout open do 589 ( 590 donotRedraw = false 591 initListView() 592 nodes = #() 593 addCallback() 594 selectionCallback() 595 ) 596 on nw4cCombineRollout close do 597 ( 598 removeCallback() 599 ) 600 601 on btnClose pressed do DestroyDialog nw4cCombineRollout 602)-- combine rollout 603 604