1-- NW4C Node Tool(2010/12/07) 2-- Version 0.5.0d 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 if donotRedraw do return() 387 lv_mtl.Items.Clear() 388 local lvItems =#() 389 390 local str = "" 391 for n in nodes do 392 ( 393 local id = getNodeCombineGroup n 394 395 local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name 396 local sub_li 397 398 str = if (id < 0) then "Don't care" 399 else str = (id as string) 400 sub_li = li.SubItems.add str 401 append lvItems li 402 ) 403 lv_mtl.Items.AddRange lvItems 404 405 if nodes.count > 0 then 406 ( 407 id = getNodeCombineGroup nodes[1] 408 --print nodes 409 if (id < 0) then 410 ( 411 rdoSetCombineType.state = 1 412 spnSetCombine.enabled = false 413 ) 414 else 415 ( 416 rdoSetCombineType.state = 2 417 spnSetCombine.enabled = true 418 spnSetCombine.value = id 419 ) 420 ) 421 ) 422 423 fn setNodesAttribute = 424 ( 425 --local mtls = getSelMtls selection 426 local attr 427 undo "Edit Combine Group" on 428 ( 429 spnSetCombine.enabled = (rdoSetCombineType.state == 2) 430 for n in nodes do 431 ( 432 attr = getNodeAttribute n true 433 local val = 0 434 if rdoSetCombineType.state == 1 then 435 ( 436 attr.combineGroup = -1 437 ) 438 else 439 ( 440 attr.combineGroup = spnSetCombine.value 441 ) 442 ) 443 ) 444 updateSelection() 445 ) 446 447 fn nodeNameCompare v1 v2 = 448 ( 449 if (v1.name > v2.name) then 1 else -1 450 ) 451 452 fn addCallback = 453 ( 454 callbacks.addScript #selectionSetChanged "nw4cCombineRollout.selectionCallback()" \ 455 id:#nw4cCombineSelectionChange 456 ) 457 fn removeCallback = 458 ( 459 callbacks.removeScripts id:#nw4cCombineSelectionChange 460 ) 461 462 fn selectionCallback = 463 ( 464 --print "selectionCallback" 465 nodes = #() 466 for n in selection do appendIfUnique nodes n 467 qsort nodes nodeNameCompare 468 updateSelection() 469 ) 470 471 fn sequenceCompare v1 v2 = 472 ( 473 local ret = 0 474 if(v1[1] > v2[1]) then 475 ( 476 ret = 1 477 ) 478 else if (v1[1] < v2[1]) then 479 ( 480 ret = -1 481 ) 482 else 483 ( 484 ret = if (v1[2].name > v2[2].name) then 1 else -1 485 ) 486 ret 487 ) 488 489 on btnSequential pressed do 490 ( 491 local seqnodes = #() 492 local id = spnSetCombine.value 493 -- �O���[�vID��255����ꍇ�̓G���[ 494 if (id + nodes.count - 1) > 255 then 495 ( 496 messageBox "Combine Group will be greater than 255" 497 return() 498 ) 499 500 for n in nodes do 501 ( 502 local depth = 0 503 local p = n 504 do 505 ( 506 depth += 1 507 p = p.parent 508 ) 509 while (p != undefined) 510 append seqnodes #(depth, n) 511 ) 512 qsort seqnodes sequenceCompare 513 --print seqnodes 514 for a in seqnodes do 515 ( 516 setNodeCombineGroup a[2] id 517 id += 1 518 ) 519 updateSelection() 520 ) 521 522 on btnSearch pressed do 523 ( 524 removeCallback() 525 clearSelection() 526 nodes = #() 527 for n in objects do 528 ( 529 --local attr = getNodeAttribute n false 530 local id = getNodeCombineGroup n 531 local ret= false 532 533 case rdoSearchCombineType.state of 534 ( 535 1: ( -- Don't care 536 if id < 0 do 537 ( 538 ret = true 539 ) 540 ) 541 2: ( -- condition 542 if id >=0 do 543 ( 544 local v = spnSearchCombine.value 545 case ddlSearchConditionType.selection of 546 ( 547 1: ( -- under 548 ret = (id < v) 549 ) 550 2: ( -- below 551 ret = (id <= v) 552 ) 553 3: ( -- exactly 554 ret = (id == v) 555 ) 556 4: ( -- above 557 ret = (id >= v) 558 ) 559 5: ( -- over 560 ret = (id > v) 561 ) 562 ) 563 ) 564 ) 565 default: ret = false 566 ) 567 568 -- ���������}�e���A����z��ɒlj� 569 if ret do 570 ( 571 appendIfUnique nodes n 572 ) 573 ) 574 575 for n in nodes do 576 ( 577 selectMore n 578 ) 579 580 updateSelection() 581 addCallback() 582 ) 583 584 on rdoSetCombineType changed i do setNodesAttribute() 585 on spnSetCombine changed i do setNodesAttribute() 586 587 on nw4cCombineRollout open do 588 ( 589 donotRedraw = false 590 initListView() 591 nodes = #() 592 addCallback() 593 selectionCallback() 594 ) 595 on nw4cCombineRollout close do 596 ( 597 removeCallback() 598 ) 599 600 on btnClose pressed do DestroyDialog nw4cCombineRollout 601)-- combine rollout 602 603rollout nw4cForceKeyRollout "NW4C Set Force Export Key" width:320 height:410 604( 605 group "Selected Nodes" 606 ( 607 dotNetControl lv_nodes "System.Windows.Forms.ListView" width:288 height:164 608 ) 609 group "Set" 610 ( 611 checkbox chkExportTrans "Force Export Translate Key" width:280 height:16 offset:[0,-4] 612 checkbox chkExportRotate "Force Export Rotate Key" width:280 height:16 offset:[0,-4] 613 checkbox chkExportScale "Force Export Scale Key" width:280 height:16 offset:[0,-4] 614 ) 615 group "Search" 616 ( 617 label lblExportTrans "Force Export Translate Key" align:#left across:4 618 label lblDummy3 "" 619 checkbox chkS_ExportTransOFF "Off" 620 checkbox chkS_ExportTransON "On" 621 label lblExportRotate "Force Export Rotate Key" align:#left across:4 622 label lblDummy2 "" 623 checkbox chkS_ExportRotateOFF "Off" 624 checkbox chkS_ExportRotateON "On" 625 label lblExportScale "Force Export Scale Key" align:#left across:4 626 label lblDummy1 "" 627 checkbox chkS_ExportScaleOFF "Off" 628 checkbox chkS_ExportScaleON "On" 629 630 radioButtons rdoSearchType "" width:98 height:16 labels:#("AND", "OR") columns:2 offset:[0,4] across:2 631 button btnSearch "Search" width:112 height:24 632 ) 633 634 button btnClose "Close" width:304 height:24 635 636 local donotRedraw 637 local nodes = #() 638 fn initListView = 639 ( 640 lv_nodes.gridLines = true 641 lv_nodes.View = (dotNetClass "System.Windows.Forms.View").Details 642 lv_nodes.fullRowSelect = true 643 lv_nodes.AutoSize = true 644 lv_nodes.MultiSelect = false 645 lv_nodes.Columns.add "Node Name " 646 lv_nodes.Columns.add "Translate" 647 lv_nodes.Columns.add "Rotate" 648 lv_nodes.Columns.add "Scale" 649 lv_nodes.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending 650 lv_nodes.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) 651 ) 652 653 fn getNodeAttribute n create = 654 ( 655 local attrib = n.custAttributes["NW4C Node Custom Attribute"] 656 if attrib == undefined then 657 ( 658 if not create do return undefined 659 attrib = nw4c_node_custom_attribute() 660 append n.custAttributes attrib 661 ) 662 return attrib 663 ) 664 665 fn setExportScale n flag = 666 ( 667 local attrib = getNodeAttribute n true 668 if attrib == undefined do return undefined 669 attrib.exportScaleKey = flag 670 ) 671 fn setExportRotate n flag = 672 ( 673 local attrib = getNodeAttribute n true 674 if attrib == undefined do return undefined 675 attrib.exportRotateKey = flag 676 ) 677 fn setExportTrans n flag = 678 ( 679 local attrib = getNodeAttribute n true 680 if attrib == undefined do return undefined 681 attrib.exportTranslateKey = flag 682 ) 683 684 fn getExportScale n = 685 ( 686 local attrib = getNodeAttribute n false 687 if attrib == undefined do return false 688 return attrib.exportScaleKey 689 ) 690 fn getExportRotate n = 691 ( 692 local attrib = getNodeAttribute n false 693 if attrib == undefined do return false 694 return attrib.exportRotateKey 695 ) 696 fn getExportTrans n = 697 ( 698 local attrib = getNodeAttribute n false 699 if attrib == undefined do return false 700 return attrib.exportTranslateKey 701 ) 702 703 fn updateSelection = 704 ( 705 if donotRedraw do return() 706 lv_nodes.Items.Clear() 707 local lvItems =#() 708 709 local str = "" 710 for n in nodes do 711 ( 712 local li = dotNetObject "System.Windows.Forms.ListViewItem" n.name 713 local sub_li 714 local attr = getNodeAttribute n false 715 if attr != undefined then --�A�g���r���[�g������ꍇ 716 ( 717 sub_li = li.SubItems.add (attr.exportTranslateKey as string) 718 sub_li = li.SubItems.add (attr.exportRotateKey as string) 719 sub_li = li.SubItems.add (attr.exportScaleKey as string) 720 ) 721 else -- �A�g���r���[�g���Ȃ��ꍇ 722 ( 723 sub_li = li.SubItems.add "false" 724 sub_li = li.SubItems.add "false" 725 sub_li = li.SubItems.add "false" 726 ) 727 append lvItems li 728 ) 729 lv_nodes.Items.AddRange lvItems 730 731 if nodes.count > 0 then 732 ( 733 chkExportScale.enabled = true 734 chkExportRotate.enabled = true 735 chkExportTrans.enabled = true 736 chkExportScale.checked = getExportScale nodes[1] 737 chkExportRotate.checked = getExportRotate nodes[1] 738 chkExportTrans.checked = getExportTrans nodes[1] 739 ) 740 else 741 ( 742 chkExportScale.enabled = false 743 chkExportRotate.enabled = false 744 chkExportTrans.enabled = false 745 ) 746 ) 747 748 749 on chkExportScale changed v do 750 ( 751 for n in nodes do 752 ( 753 setExportScale n v 754 ) 755 updateSelection() 756 ) 757 on chkExportRotate changed v do 758 ( 759 for n in nodes do 760 ( 761 setExportRotate n v 762 ) 763 updateSelection() 764 ) 765 on chkExportTrans changed v do 766 ( 767 for n in nodes do 768 ( 769 setExportTrans n v 770 ) 771 updateSelection() 772 ) 773 774 fn addCallback = 775 ( 776 callbacks.addScript #selectionSetChanged "nw4cForceKeyRollout.selectionCallback()" \ 777 id:#nw4cForceKeySelectionChange 778 ) 779 fn removeCallback = 780 ( 781 callbacks.removeScripts id:#nw4cForceKeySelectionChange 782 ) 783 fn selectionCallback = 784 ( 785 nodes = #() 786 for n in selection do appendIfUnique nodes n 787 updateSelection() 788 ) 789 790 on nw4cForceKeyRollout open do 791 ( 792 donotRedraw = false 793 initListView() 794 nodes = #() 795 addCallback() 796 selectionCallback() 797 ) 798 on nw4cForceKeyRollout close do 799 ( 800 removeCallback() 801 ) 802 on btnSearch pressed do 803 ( 804 removeCallback() 805 clearSelection() 806 nodes = #() 807 local bScaleON = chkS_ExportScaleON.checked 808 local bScaleOFF = chkS_ExportScaleOFF.checked 809 local bRotON = chkS_ExportRotateON.checked 810 local bRotOFF = chkS_ExportRotateOFF.checked 811 local bTransON = chkS_ExportTransON.checked 812 local bTransOFF = chkS_ExportTransOFF.checked 813 814 local scaleKey, rotKey, transKey 815 816 local isSearchAnd = if rdoSearchType.state == 1 then true else false 817 local isSearchOr = not isSearchAnd 818 819 for n in objects do 820 ( 821 local attr = getNodeAttribute n false 822 if attr == undefined then 823 ( 824 scaleKey = rotKey = transKey = false 825 ) 826 else 827 ( 828 scaleKey = attr.exportScaleKey 829 rotKey = attr.exportRotateKey 830 transKey = attr.exportTranslateKey 831 ) 832 833 local compare = true -- ���̏����Ŕ�r���邩�ǂ����H 834 local ret =false -- ���̃m�[�h����r�������������ǂ��� 835 836 -- scale 837 if (bScaleON or bScaleOFF) and compare do 838 ( 839 ret = (scaleKey == bScaleON) or ((not scaleKey) == bScaleOFF) 840 if ret and isSearchOr then compare = false 841 else if (not ret) and isSearchAnd do compare = false 842 ) 843 -- rotate 844 if (bRotON or bRotOFF) and compare do 845 ( 846 ret = (rotKey == bRotON) or ((not rotKey) == bRotOFF) 847 if ret and isSearchOr then compare = false 848 else if (not ret) and isSearchAnd do compare = false 849 ) 850 -- translate 851 if (bTransON or bTransOFF) and compare do 852 ( 853 ret = (transKey == bTransON) or ((not transKey) == bTransOFF) 854 if ret and isSearchOr then compare = false 855 else if (not ret) and isSearchAnd do compare = false 856 ) 857 858 -- ���������m�[�h��z��ɒlj� 859 if ret do 860 ( 861 appendIfUnique nodes n 862 ) 863 ) 864 865 for n in nodes do 866 ( 867 selectMore n 868 ) 869 updateSelection() 870 addCallback() 871 ) 872 873 on btnClose pressed do DestroyDialog nw4cForceKeyRollout 874)-- Set Force Export Key rollout 875 876rollout nw4cNodeUserDataRollout "NW4C Set User Data" width:480 height:290 877( 878 group "Selected Node" 879 ( 880 label lblNode 881 --dotNetControl lv_nodes "System.Windows.Forms.ListView" width:288 height:164 882 ) 883 group "Edit Data" 884 ( 885 button btnUp "Move Up" across:5 886 button btnDown "Move Down" 887 button btnAdd "Add..." 888 button btnDelete "Delete" 889 button btnEdit "Edit..." 890 dotNetControl lv_data "System.Windows.Forms.ListView" width:450 height:164 891 ) 892 button btnClose "Close" width:474 height:24 893 894 local utils = nw4c_utils() 895 local donotRedraw 896 local nodes = #() 897 local dataset = undefined 898 899 fn getNodeAttribute n create = 900 ( 901 local attrib = n.custAttributes["NW4C Node Custom Attribute"] 902 if attrib == undefined then 903 ( 904 if not create do return undefined 905 attrib = nw4c_node_custom_attribute() 906 append n.custAttributes attrib 907 ) 908 return attrib 909 ) 910 911 fn initListView = 912 ( 913 lv_data.gridLines = true 914 lv_data.View = (dotNetClass "System.Windows.Forms.View").Details 915 lv_data.fullRowSelect = true 916 lv_data.AutoSize = true 917 lv_data.MultiSelect = false 918 lv_data.Columns.add " Name " 919 lv_data.Columns.add " Type " 920 lv_data.Columns.add " Size" 921 lv_data.Columns.add " Value" 922 --lv_data.sorting = (dotNetClass "System.Windows.Forms.SortOrder").Ascending 923 lv_data.AutoResizeColumns ((dotNetClass "System.Windows.Forms.ColumnHeaderAutoResizeStyle").HeaderSize) 924 ) 925 926 fn saveData = 927 ( 928 -- 1�����I�����ꂽ�Ƃ������������� 929 if nodes.count != 1 do return() 930 931 local n = nodes[1] 932 local attr = getNodeAttribute n true 933 if attr != undefined do 934 ( 935 attr.userSettings = dataset.toString() 936 ) 937 ) 938 939 fn updateSelection = 940 ( 941 if donotRedraw do return() 942 lv_data.Items.Clear() 943 dataset = nw4c_userDataSet() 944 945 local lvItems =#() 946 947 -- 1�����I�����ꂽ�Ƃ������������� 948 if nodes.count == 1 then 949 ( 950 lblNode.text = nodes[1].name 951 btnUp.enabled = true 952 btnDown.enabled = true 953 btnAdd.enabled = true 954 btnDelete.enabled = true 955 btnEdit.enabled = true 956 ) 957 else 958 ( 959 lblNode.text = "" 960 btnUp.enabled = false 961 btnDown.enabled = false 962 btnAdd.enabled = false 963 btnDelete.enabled = false 964 btnEdit.enabled = false 965 return () 966 ) 967 968 local n = nodes[1] 969 local attr = getNodeAttribute n false 970 if attr != undefined then --�A�g���r���[�g������ꍇ 971 ( 972 local str = attr.userSettings 973 if (classof str) == String do 974 ( 975 local ret = dataset.fromString str 976 if ret do 977 ( 978 for i = 1 to dataset.list.count do 979 ( 980 local data = dataset.list[i] 981 local li = dotNetObject "System.Windows.Forms.ListViewItem" data.dataname 982 local sub_li 983 sub_li = li.SubItems.add (data.type as String) 984 sub_li = li.SubItems.add ((data.valueCount()) as string) 985 sub_li = li.SubItems.add ((data.valueToString oneline:true) as string) 986 append lvItems li 987 ) 988 ) 989 ) 990 ) 991 else -- �A�g���r���[�g���Ȃ��ꍇ 992 ( 993 ) 994 lv_data.Items.AddRange lvItems 995 ) 996 997 998 999 fn addCallback = 1000 ( 1001 callbacks.addScript #selectionSetChanged "nw4cNodeUserDataRollout.selectionCallback()" \ 1002 id:#nw4cNodeUserDataSelectionChange 1003 ) 1004 fn removeCallback = 1005 ( 1006 callbacks.removeScripts id:#nw4cNodeUserDataSelectionChange 1007 ) 1008 fn selectionCallback = 1009 ( 1010 nodes = #() 1011 for n in selection do appendIfUnique nodes n 1012 updateSelection() 1013 ) 1014 1015 fn EditData data add = 1016 ( 1017 nw4cEditUserDataRollout_ValueSet = dataset 1018 nw4cEditUserDataRollout_Value = data 1019 CreateDialog nw4cEditUserDataRollout modal:true 1020 if nw4cEditUserDataRollout_Value != undefined do 1021 ( 1022 if add do dataset.appendData nw4cEditUserDataRollout_Value 1023 saveData() 1024 updateSelection() 1025 ) 1026 ) 1027 1028 on nw4cNodeUserDataRollout open do 1029 ( 1030 donotRedraw = false 1031 initListView() 1032 nodes = #() 1033 addCallback() 1034 selectionCallback() 1035 ) 1036 on nw4cNodeUserDataRollout close do 1037 ( 1038 removeCallback() 1039 ) 1040 1041 on btnUp pressed do 1042 ( 1043 if lv_data.SelectedIndices.Count > 0 do 1044 ( 1045 local id = lv_data.SelectedIndices.Item[0] 1046 local maxid = id + 1 1047 if id > 0 do 1048 ( 1049 local tmp = dataset.list[maxid] 1050 deleteItem dataset.list (maxid) 1051 insertItem tmp dataset.list (maxid - 1) 1052 saveData() 1053 updateSelection() 1054 lv_data.Items.Item[id-1].Selected = true 1055 ) 1056 lv_data.Focus() 1057 ) 1058 ) 1059 on btnDown pressed do 1060 ( 1061 if lv_data.SelectedIndices.Count > 0 do 1062 ( 1063 local id = lv_data.SelectedIndices.Item[0] 1064 local maxid = id + 1 1065 if maxid < dataset.list.count do 1066 ( 1067 local tmp = dataset.list[maxid] 1068 deleteItem dataset.list (maxid) 1069 insertItem tmp dataset.list (maxid + 1) 1070 saveData() 1071 updateSelection() 1072 lv_data.Items.Item[id+1].Selected = true 1073 ) 1074 lv_data.Focus() 1075 ) 1076 ) 1077 1078 on btnDelete pressed do 1079 ( 1080 if lv_data.SelectedIndices.Count > 0 do 1081 ( 1082 local id = lv_data.SelectedIndices.Item[0] 1083 local maxid = id + 1 1084 ( 1085 deleteItem dataset.list (maxid) 1086 saveData() 1087 updateSelection() 1088 ) 1089 lv_data.Focus() 1090 ) 1091 ) 1092 1093 on btnAdd pressed do 1094 ( 1095 if (classof dataset) == nw4c_userDataSet do 1096 ( 1097 editData (nw4c_userData()) true 1098 ) 1099 ) 1100 1101 on btnEdit pressed do 1102 ( 1103 if (classof dataset) == nw4c_userDataSet do 1104 ( 1105 if lv_data.SelectedIndices.Count > 0 do 1106 ( 1107 local id = lv_data.SelectedIndices.Item[0] 1108 local maxid = id + 1 1109 editData (dataset.list[maxid]) false 1110 ) 1111 ) 1112 ) 1113 1114 on btnClose pressed do DestroyDialog nw4cNodeUserDataRollout 1115)-- Set User Data 1116 1117