-- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "LK_Tagger" -- ************************************************** -- General information about this script -- ************************************************** LK_Tagger = {} function LK_Tagger:ColorizeIcon() return true end function LK_Tagger:Name() return "Layer tagger" end function LK_Tagger:Version() return "0.2" end function LK_Tagger:Description() return "Toggle the buttons to add/remove tags from the current layer. And filter the layer window by tag." end function LK_Tagger:Creator() return "Lukas Krepel Frame Order" end function LK_Tagger:UILabel() return "Tag layers" end function LK_Tagger:OnMouseDown(moho, mouseEvent) end -- ************************************************** -- Is Relevant / Is Enabled -- ************************************************** function LK_Tagger:IsEnabled(moho) return true end function LK_Tagger:IsRelevant(moho) local rtx = true if MohoMode ~= nil then rtx = MohoMode.rigging end return rtx end -- ************************************************** -- Tool options - create and respond to tool's UI -- ************************************************** LK_Tagger.CLEAR_TAGS = MOHO.MSG_BASE + 0 LK_Tagger.TAG_RIG = MOHO.MSG_BASE + 1 LK_Tagger.TAG_ANIM = MOHO.MSG_BASE + 2 LK_Tagger.TAG_OUTFIT = MOHO.MSG_BASE + 13 LK_Tagger.CHANGE_TAGS = MOHO.MSG_BASE + 14 LK_Tagger.LAYERFILTER_NOFILTER = MOHO.MSG_BASE + 3 LK_Tagger.LAYERFILTER_TAG_RIG = MOHO.MSG_BASE + 4 LK_Tagger.LAYERFILTER_TAG_ANIM = MOHO.MSG_BASE + 5 LK_Tagger.RIG_LAYERS_EXPOSE_TIMELINE = MOHO.MSG_BASE + 6 LK_Tagger.ANIM_LAYERS_EXPOSE_TIMELINE = MOHO.MSG_BASE + 7 LK_Tagger.CLEAR_TIMELINE = MOHO.MSG_BASE + 8 LK_Tagger.EXPAND_GROUPS = MOHO.MSG_BASE + 9 LK_Tagger.COLLAPSE_GROUPS = MOHO.MSG_BASE + 10 LK_Tagger.CLEAN_ANIM_TAGS = MOHO.MSG_BASE + 11 LK_Tagger.LAYERFILTER_GROUPNAME_RIGNAME = MOHO.MSG_BASE + 12 LK_Tagger.OPTION = MOHO.MSG_BASE + 100 function LK_Tagger:DoLayout(moho, layout) local layer = moho.document:GetSelectedLayer(0) tags = layer:UserTags() -- *** Current layer's tags *** layout:PushH(LM.GUI.ALIGN_CENTER, 2) FO_Utilities:Divider(layout, "Current layer's tags", true) self.currentTags = LM.GUI.TextControl(250, "no tags", self.CHANGE_TAGS, 0, nil) -- * 0 = LM.GUI.FIELD_TEXT layout:AddChild(self.currentTags) --BUTTON: Clear tags self.Clear_Tags_Button = LM.GUI.ImageButton("ScriptResources/FO_icons/trashcan", "Clear all tags", false, self.CLEAR_TAGS, true) layout:AddChild(self.Clear_Tags_Button) layout:Pop() -- *** Add tag: *** FO_Utilities:Divider(layout, "Add tag") layout:PushH(LM.GUI.ALIGN_CENTER, 2) self.Tag_Rig_Button = LM.GUI.ImageButton("ScriptResources/FO_icons//tag_rig", "Tag as rig layer", true, self.TAG_RIG, true) layout:AddChild(self.Tag_Rig_Button) --BUTTON: Tag as "anim" self.Tag_Anim_Button = LM.GUI.ImageButton("ScriptResources/FO_icons//tag_anim", "Tag as anim layer", true, self.TAG_ANIM, true) layout:AddChild(self.Tag_Anim_Button) --BUTTON: Tag as "outfit" self.Tag_Outfit_Button = LM.GUI.ImageButton("ScriptResources/FO_icons//tag_outfit", "Tag as outfit layer", true, self.TAG_OUTFIT, true) layout:AddChild(self.Tag_Outfit_Button) layout:Pop() --DIVIDER FO_Utilities:Divider(layout, "Expose on timeline") layout:PushH(LM.GUI.ALIGN_CENTER, 2) --BUTTON: Show "rig" layers on timeline self.Show_Timeline_Tag_Rig_Button = LM.GUI.ImageButton("ScriptResources/FO_icons/timeline_rig", "Show all rig layers on the timeline", false, self.RIG_LAYERS_EXPOSE_TIMELINE, true) layout:AddChild(self.Show_Timeline_Tag_Rig_Button) --BUTTON: Show "anim" layers on timeline self.Show_Timeline_Tag_Anim_Button = LM.GUI.ImageButton("ScriptResources/FO_icons/timeline_anim", "Show all anim layers on the timeline", false, self.ANIM_LAYERS_EXPOSE_TIMELINE, true) layout:AddChild(self.Show_Timeline_Tag_Anim_Button) --BUTTON: Clear shown layers on timeline self.Clear_Timeline_Button = LM.GUI.ImageButton("ScriptResources/FO_icons/timeline_clear", "Clear shown layers on the timeline", false, self.CLEAR_TIMELINE, true) layout:AddChild(self.Clear_Timeline_Button) layout:Pop() --DIVIDER FO_Utilities:Divider(layout, "Select rig") --DROPDOWN MENU self.menu = LM.GUI.Menu("Select rig") self.popup = LM.GUI.PopupMenu(120, false) self.popup:SetMenu(self.menu) layout:AddChild(self.popup) --DIVIDER FO_Utilities:Divider(layout, "Layers-panel filter") layout:PushH(LM.GUI.ALIGN_CENTER, 2) --BUTTOn: Filter tag "rig" self.filterRigTagButton = LM.GUI.ImageButton("ScriptResources/FO_icons/filter_tag_rig", "Show rig layers", true, self.LAYERFILTER_TAG_RIG, true) layout:AddChild(self.filterRigTagButton) --BUTTOn: Filter tag "anim" self.filterAnimTagButton = LM.GUI.ImageButton("ScriptResources/FO_icons/filter_tag_anim", "Show animation layers", true, self.LAYERFILTER_TAG_ANIM, true) layout:AddChild(self.filterAnimTagButton) --BUTTON: Filter name currentrigname self.filterNameRignameButton = LM.GUI.ImageButton("ScriptResources/FO_icons/filter_groupname_rigname", "Show entire current rig", true, self.LAYERFILTER_GROUPNAME_RIGNAME, true) layout:AddChild(self.filterNameRignameButton) --BUTTON: Filter "No filter" self.filterNoFilterButton = LM.GUI.ImageButton("ScriptResources/FO_icons/filter_clear", "Show all layers", false, self.LAYERFILTER_NOFILTER, true) layout:AddChild(self.filterNoFilterButton) layout:Pop() --DIVIDER FO_Utilities:Divider(layout, "Groups") layout:PushH(LM.GUI.ALIGN_CENTER, 2) --BUTTON: Collapse groups self.collapseGroupsButton = LM.GUI.ImageButton("ScriptResources/FO_icons/groups_collapse", "Collapse all groups", false, self.COLLAPSE_GROUPS, true) layout:AddChild(self.collapseGroupsButton) --BUTTON: Expand groups self.expandGroupsButton = LM.GUI.ImageButton("ScriptResources/FO_icons/groups_expand", "Expand all groups", false, self.EXPAND_GROUPS, true) layout:AddChild(self.expandGroupsButton) layout:Pop() --DIVIDER FO_Utilities:Divider(layout, "Clear all anim tags") --BUTTON: Tag as "rig" self.Clean_Anim_Tag_Button = LM.GUI.ImageButton("ScriptResources/FO_icons/trashcan", "Clear anim tags from layers without keys", false, self.CLEAN_ANIM_TAGS, true) layout:AddChild(self.Clean_Anim_Tag_Button) end function LK_Tagger:UpdateWidgets(moho) -- * Find all rigs and put them in the dropdown menu self.menu:RemoveAllItems() local taglayers = FO_Utilities:ListLayersWithTag(FO_Utilities.rigTag, moho) local i for i = 1, #taglayers do local layer = taglayers[i] local rigname = layer:Name() self.menu:AddItem(rigname, 0, (self.OPTION + i)) end -- *** Tags -- * Update Rig tag button local layer = moho.document:GetSelectedLayer(0) local tags = layer:UserTags() if string.match(tags, FO_Utilities.rigTag) then self.Tag_Rig_Button:SetValue(true) else self.Tag_Rig_Button:SetValue(false) end -- * Update Anim tag button if string.match(tags, FO_Utilities.animTag) then self.Tag_Anim_Button:SetValue(true) else self.Tag_Anim_Button:SetValue(false) end -- * Update Outfit tag button if string.match(tags, FO_Utilities.outfitTag) then self.Tag_Outfit_Button:SetValue(true) else self.Tag_Outfit_Button:SetValue(false) end --Update Layer filter buttons --[[if (moho:LayersWindowGetSearchContext() == 0) or moho:LayersWindowGetSearchContextValue() == "" then self.filterNoFilterButton:SetValue(true) else self.filterNoFilterButton:SetValue(false) end]] if (moho:LayersWindowGetSearchContext() == 8 and moho:LayersWindowGetSearchContextValue() == FO_Utilities.rigTag) then self.filterRigTagButton:SetValue(true) else self.filterRigTagButton:SetValue(false) end if (moho:LayersWindowGetSearchContext() == 8 and moho:LayersWindowGetSearchContextValue() == FO_Utilities.animTag) then self.filterAnimTagButton:SetValue(true) else self.filterAnimTagButton:SetValue(false) end if (moho:LayersWindowGetSearchContext() == 2) then -- Nodig om naam te checken??? self.filterNameRignameButton:SetValue(true) else self.filterNameRignameButton:SetValue(false) end if string.match(tags, FO_Utilities.rigTag) then -- Of parent is rig, nog fixen ??? self.filterNameRignameButton:Enable(true) else self.filterNameRignameButton:Enable(false) end -- * Multiple layers selected tags = layer:UserTags() local selCount = moho.document:CountSelectedLayers() if selCount > 1 then for i = 0, selCount - 1 do local layer = moho.document:GetSelectedLayer(i) if (tags ~= layer:UserTags()) then tagsDontMatch = true else tagsDontMatch = false end end if tagsDontMatch == true then self.currentTags:SetValue("Not all selected layers have identical tags.") self.currentTags:Enable(false) else self.currentTags:SetValue(tags) self.currentTags:Enable(true) end else tagsDontMatch = false self.currentTags:SetValue(tags) self.currentTags:Enable(true) end end -- ************************************************** -- The guts of this script -- ************************************************** function LK_Tagger:HandleMessage(moho, view, msg) do_expose_tag_on_timeline = false do_on_all_layers = false do_toggle_layertag = false tag = nil first_match = nil if (moho:Skeleton() ~= nil) then -- Eigenlijk ook kijken of parent een rig is en dan die name pakken, maarja nog fixen LUKAS ??? rigname = moho.layer:Name() end -- *** Check which message *** if msg == self.CLEAR_TAGS then moho.document:PrepMultiUndo() moho.document:SetDirty() local selCount = moho.document:CountSelectedLayers() for i = 0, selCount - 1 do local layer = moho.document:GetSelectedLayer(i) layer:SetUserTags("") end -- *** Tags *** elseif msg == self.TAG_RIG then moho.document:PrepMultiUndo() moho.document:SetDirty() FO_Utilities:ToggleTagSelectedLayers(FO_Utilities.rigTag, moho) elseif msg == self.TAG_ANIM then moho.document:PrepMultiUndo() moho.document:SetDirty() FO_Utilities:ToggleTagSelectedLayers(FO_Utilities.animTag, moho) elseif msg == self.TAG_OUTFIT then moho.document:PrepMultiUndo() moho.document:SetDirty() FO_Utilities:ToggleTagSelectedLayers(FO_Utilities.outfitTag, moho) -- *** Filters *** elseif msg == self.LAYERFILTER_TAG_RIG then FO_Utilities:FilterTag(FO_Utilities.rigTag, false, moho) elseif msg == self.LAYERFILTER_GROUPNAME_RIGNAME then FO_Utilities:FilterGroupname(rigname, moho) elseif msg == self.LAYERFILTER_TAG_ANIM then FO_Utilities:FilterTag(FO_Utilities.animTag, false, moho) elseif msg == self.LAYERFILTER_NOFILTER then moho:LayersWindowSetSearchContext(0) -- 0 = LAYERWND_SEARCHCONTEXT_ALL moho:LayersWindowSetSearchContextValue("") elseif msg == self.ANIM_LAYERS_EXPOSE_TIMELINE then FO_Utilities:FilterTag(FO_Utilities.animTag, true, moho) -- ??? elseif msg == self.RIG_LAYERS_EXPOSE_TIMELINE then FO_Utilities:FilterTag(FO_Utilities.rigTag, true, moho) -- ??? elseif msg == self.CLEAR_TIMELINE then local layers = FO_Utilities:AllLayers(moho) local i for i = 1, #layers do layer = layers[i] layer:SetShownOnTimeline(false) end elseif msg == self.EXPAND_GROUPS then local layers = FO_Utilities:AllLayers(moho) local i for i = 1, #layers do layer = layers[i] if layer:IsGroupType() == true then layer:Expand(true) end end elseif msg == self.COLLAPSE_GROUPS then local layers = FO_Utilities:AllLayers(moho) local i for i = 1, #layers do layer = layers[i] if layer:IsGroupType() == true then layer:Expand(false) end end moho:ShowLayerInLayersPalette(moho.layer) elseif msg == self.CLEAN_ANIM_TAGS then -- moho.document:PrepMultiUndo() moho.document:SetDirty() local layers = FO_Utilities:AllLayers(moho) for i = 1, #layers do local layer = layers[i] if not string.match(layer:UserTags(), FO_Utilities.rigTag) then FO_Utilities:RemoveTag(FO_Utilities.animTag, layer, moho) end end -- elseif msg > self.OPTION then local option = (msg - self.OPTION) local taglayers = FO_Utilities:ListLayersWithTag(FO_Utilities.rigTag, moho) -- * ? local rig = taglayers[option] moho:SetSelLayer(rig, false, false) rigname = moho.layer:Name() --Eerst alle vinkjes uitzetten local layers = FO_Utilities:AllLayers(moho) for i = 1, #layers do local layer = layers[i] layer:SetShownOnTimeline(false) end --begin nieuw stuk if rig:LayerType() == 4 then local layer = moho:LayerAsGroup(rig) FO_Utilities:ShowAnimChildLayersOnTimeline(layer) -- Recursive door alle lagen gaan en anim layers op settimelinevisible true zetten end rig:SetShownOnTimeline(true) if (moho:LayersWindowGetSearchContext() == 2) then -- Niet helemaal zuiver moho:LayersWindowSetSearchContextValue(rigname) end end -- Update UI moho:UpdateUI() end
Tagger
Listed
Author: Lukas
View Script
Script type: Tool
Uploaded: Sep 26 2023, 14:34
Script Version: 0.2
Quickly tag layers with 'rig' or 'anim' tags.
Toggle the buttons to add/remove tags from the current layer. And filter the layer window by tag.
This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 663
Tagger
Listed
Author: Lukas
View Script
Script type: Tool
Uploaded: Sep 26 2023, 14:34
Script Version: 0.2
Quickly tag layers with 'rig' or 'anim' tags.
Toggle the buttons to add/remove tags from the current layer. And filter the layer window by tag.
This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 663