From 343dd16c31bf72fb3b6db66cb9e4c8162271611e Mon Sep 17 00:00:00 2001 From: Chev Date: Sun, 16 Jul 2023 21:03:27 -0700 Subject: [PATCH] Screenshot Editor: Improve initialization; proper reload on autorefresh --- .../lua/autorun/client/cl_screenshoteditor.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/screenshot_editor/lua/autorun/client/cl_screenshoteditor.lua b/addons/screenshot_editor/lua/autorun/client/cl_screenshoteditor.lua index d6542fd..b61c55d 100644 --- a/addons/screenshot_editor/lua/autorun/client/cl_screenshoteditor.lua +++ b/addons/screenshot_editor/lua/autorun/client/cl_screenshoteditor.lua @@ -156,8 +156,15 @@ concommand.Add("screenshot_editor", function(ply, cmd, args, argStr) screenshot_editor.PANEL = mainWindow end) -hook.Add("Initialize", "RunScreenshotEditorInitialize", function() - hook.Run("ScreenshotEditorInitialize") -end) +local function InitializeScreenshotEditorHook() + table.Empty(FILTER_DATA) + table.Empty(FRAME_DATA) ---if game.GetWorld() ~= NULL then hook.Run("ScreenshotEditorInitialize") end + hook.Run("ScreenshotEditorInitialize") +end + +hook.Add("Initialize", "RunScreenshotEditorInitialize_OnGamemodeInitialize", InitializeScreenshotEditorHook) +hook.Add("OnReloaded", "RunScreenshotEditorInitialize_OnReloaded", InitializeScreenshotEditorHook) + +-- Debug autorefresh +if game.GetWorld() ~= NULL then InitializeScreenshotEditorHook() end