Changing ghost convars will now update ghost state, + formatting

This commit is contained in:
penolakushari 2022-10-02 09:07:43 +03:00
parent 7218a561e2
commit b9d92041fb
4 changed files with 33 additions and 5 deletions

View File

@ -303,6 +303,10 @@ function CTRL.UpdateSettings(newSettings)
SMH.Settings.Update(newSettings)
end
function CTRL.UpdateUISetting(setting, value)
SMH.UI.UpdateUISetting(setting, value)
end
function CTRL.OpenHelp()
gui.OpenURL("https://github.com/Winded/StopMotionHelper/blob/master/TUTORIAL.md")
end

View File

@ -4,6 +4,14 @@ local ConVarType = {
Float = 3,
}
local GhostVars = {
smh_ghostprevframe = "GhostPrevFrame",
smh_ghostnextframe = "GhostNextFrame",
smh_ghostallentities = "GhostAllEntities",
smh_ghosttransparency = "GhostTransparency",
smh_onionskin = "OnionSkin"
}
local TYPED_CV = {}
TYPED_CV.__index = TYPED_CV
@ -42,6 +50,15 @@ local function CreateTypedConVar(type, name, defaultValue, helptext)
}
setmetatable(cv, TYPED_CV)
if GhostVars[name] then
cvars.AddChangeCallback(name, function(convar, oldvalue, newvalue)
if oldvalue == newvalue then return end
SMH.Controller.UpdateUISetting(GhostVars[name], newvalue)
SMH.Controller.UpdateGhostState()
end)
end
return cv
end
@ -59,6 +76,7 @@ local ConVars = {
EnableWorld = CreateTypedConVar(ConVarType.Bool, "smh_enableworldkeyframes", false),
}
local MGR = {}
function MGR.GetAll()

View File

@ -771,6 +771,12 @@ function MGR.RefreshTimelineSettings()
PropertiesMenu:UpdateTimelineSettings()
end
function MGR.UpdateUISetting(setting, value)
local settings = {}
settings[setting] = value
WorldClicker.Settings:ApplySettings(settings)
end
function MGR.SetTimeline(timeline)
WorldClicker.MainMenu:UpdateTimelines(timeline)
PropertiesMenu:UpdateTimelineInfo(timeline)

View File

@ -104,7 +104,7 @@ function MGR.StartPlayback(player, startFrame, endFrame, playbackRate, settings)
EndFrame = endFrame,
PlaybackRate = playbackRate,
CurrentFrame = startFrame,
PrevFrame = startFrame - 1,
PrevFrame = startFrame - 1,
Timer = 0,
Settings = settings,
}
@ -131,10 +131,10 @@ hook.Add("Think", "SMHPlaybackManagerThink", function()
playback.Timer = 0
end
if playback.CurrentFrame ~= playback.PrevFrame then
playback.PrevFrame = playback.CurrentFrame
MGR.SetFrame(player, playback.CurrentFrame, playback.Settings)
end
if playback.CurrentFrame ~= playback.PrevFrame then
playback.PrevFrame = playback.CurrentFrame
MGR.SetFrame(player, playback.CurrentFrame, playback.Settings)
end
end
else