macroScript SetActiveGrid category:"eqko" tooltip:"Set Active Grid" buttonText:"Set Active Grid" ( -- Variável global para controle do painel global eqko_SetActiveGrid_Floater fn Toggle_SetActiveGrid_Dialog = ( -- Caso contrário, cria um novo painel dockável clearListener() rollout SetActiveGrid "Set Active Grid" ( local gridHelpers = #() local gridHelpersName = #("Home Grid") local isScrollMode = true local filterText = "" label lbl_title "Select a grid to activate:" align:#left offset:[0, 5] edittext txt_filter "Filter Grids:" text:"" width:180 align:#center offset:[0, 5] listbox lb_grids "Available Grids:" items:gridHelpersName height:5 align:#center offset:[0, 5] checkbox chk_scroll "Enable Scroll Mode" checked:isScrollMode align:#left offset:[0, 5] button btn_activate "Activate Grid" width:120 height:25 align:#center offset:[0, 5] fn refreshGridList = ( gridHelpers = for obj in objects where classOf obj == Grid collect obj gridHelpersName = #("Home Grid") if filterText == "" then ( for i = 1 to gridHelpers.count do append gridHelpersName gridHelpers[i].name ) else ( for i = 1 to gridHelpers.count where (matchPattern gridHelpers[i].name pattern:("*" + filterText + "*") ignoreCase:true) do ( append gridHelpersName gridHelpers[i].name ) ) lb_grids.items = gridHelpersName if isScrollMode then lb_grids.height = (amin #(gridHelpersName.count * 35, 150)) else lb_grids.height = gridHelpersName.count * 15 ) fn activateSelectedGrid index = ( if index == 0 then ( messageBox "No grid selected!" title:"Set Active Grid" return false ) if index == 1 then ( if activeGrid != undefined do activeGrid = undefined messageBox "Home Grid activated." title:"Set Active Grid" ) else if index <= gridHelpersName.count do ( local gridName = gridHelpersName[index] local targetGrid = for obj in gridHelpers where obj.name == gridName collect obj if targetGrid.count > 0 then ( select targetGrid[1] max activate grid object deselect targetGrid[1] messageBox ("Activated grid: " + gridName) title:"Set Active Grid" ) else ( messageBox "Selected grid not found!" title:"Set Active Grid" ) ) ) on SetActiveGrid open do ( refreshGridList() if gridHelpers.count == 0 and lb_grids.items.count == 1 then messageBox "No custom grids found in the scene." title:"Set Active Grid" ) on txt_filter changed text do ( filterText = text refreshGridList() ) on lb_grids doubleClicked index do activateSelectedGrid index on btn_activate pressed do activateSelectedGrid lb_grids.selection on chk_scroll changed state do ( isScrollMode = state refreshGridList() ) ) -- Centraliza a janela local maxWinSize = GetMAXWindowSize() local maxWinPos = GetMAXWindowPos() local dialogWidth = 200 local dialogHeight = 240 local posX = maxWinPos.x + (maxWinSize.x - dialogWidth) / 2 local posY = maxWinPos.y + (maxWinSize.y - dialogHeight) / 2 createDialog SetActiveGrid width:dialogWidth height:dialogHeight pos:[posX, posY] style:#(#style_toolwindow, #style_sysmenu, #style_resizing) dockable:true eqko_SetActiveGrid_Floater = SetActiveGrid ) -- Quando clicar no botão da toolbar ? alterna abrir/fechar Toggle_SetActiveGrid_Dialog() )