Skip to content

Commit

Permalink
use part selection for anim frame event
Browse files Browse the repository at this point in the history
  • Loading branch information
Yagira committed Nov 18, 2023
1 parent ab7d14d commit 415e36f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lua/pac3/core/client/parts/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1452,20 +1452,7 @@ do
return part:GetName()
end,
args = {
{"animation", "string", {
enums = function(part)
local output = {}
local parts = pac.GetLocalParts()

for i, part in pairs(parts) do
if part.ClassName == "custom_animation" then
output[i] = part
end
end

return output
end
}},
{"animation", "string", {editor_panel = "custom_animation_frame"}},
{"frame_start", "number", {
editor_onchange = function(self, num)
local anim = pace.current_part:GetProperty("animation")
Expand Down Expand Up @@ -1504,6 +1491,7 @@ do
if v == ent then
local part = pac.GetPartFromUniqueID(pac.Hash(ent), animation)
if not IsValid(part) then return end
if part.ClassName ~= "custom_animation" then return end
local frame, delta = animations.GetEntityAnimationFrame(ent, part:GetAnimID())
if not frame or not delta then return end -- different animation part is playing
return frame >= frame_start and frame <= frame_end
Expand Down
66 changes: 66 additions & 0 deletions lua/pac3/editor/client/panels/extra_properties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,72 @@ do -- part
pace.RegisterPanel(PANEL)
end

do -- custom animation frame event
local PANEL = {}

PANEL.ClassName = "properties_custom_animation_frame"
PANEL.Base = "pace_properties_part"

function PANEL:MoreOptionsLeftClick()
pace.CreateSearchList(
self,
self.CurrentKey,
L"custom animations",

function(list)
list:AddColumn(L"name")
list:AddColumn(L"id")
end,

function()
local output = {}
local parts = pac.GetLocalParts()

for i, part in pairs(parts) do

if part.ClassName == "custom_animation" then
local name = part.Name ~= "" and part.Name or "no name"
output[i] = name
end
end

return output
end,

function() return pace.current_part:GetProperty("animation") end,

function(list, key, val)
return list:AddLine(val, key)
end,

function(key, val) return val end,

function(key, val) return key end
)
end

function PANEL:MoreOptionsRightClick(key)
local menu = DermaMenu()

menu:MakePopup()

for _, part in pairs(pac.GetLocalParts()) do
if not part:HasParent() and part:GetShowInEditor() then
populate_part_menu(menu, part, function(part)
if not self:IsValid() then return end
if part.ClassName ~= "custom_animation" then return end
self:SetValue(part:GetUniqueID())
self.OnValueChanged(part:GetUniqueID())
end)
end
end

pace.FixMenu(menu)
end

pace.RegisterPanel(PANEL)
end

do -- owner
local PANEL = {}

Expand Down

0 comments on commit 415e36f

Please sign in to comment.