From 55f5b99094a89c33346a5937bd9f933276595d3c Mon Sep 17 00:00:00 2001 From: Linventif Date: Wed, 21 Aug 2024 18:09:16 +0000 Subject: [PATCH] Feat: add screenshot data --- lua/gmod_integration/client/cl_main.lua | 58 ++++++++++++++++++- lua/gmod_integration/client/cl_report_bug.lua | 4 +- .../client/cl_screenshots.lua | 8 ++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/lua/gmod_integration/client/cl_main.lua b/lua/gmod_integration/client/cl_main.lua index 29f5ece..f4028c3 100644 --- a/lua/gmod_integration/client/cl_main.lua +++ b/lua/gmod_integration/client/cl_main.lua @@ -42,4 +42,60 @@ function gmInte.openAdminConfig() end gmInte.SendNet("getConfig") -end \ No newline at end of file +end + +hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function() + if !gmInte.showScreenshotInfo then return end + local screenInfo = { + { + txt = "Server ID", + val = gmInte.config.id + }, + { + txt = "SteamID64", + val = LocalPlayer():SteamID64() + }, + { + txt = "Date", + val = os.date("%Y-%m-%d %H:%M:%S") + }, + { + txt = "Position", + val = function() + local pos = LocalPlayer():GetPos() + local newPos = "" + for i = 1, 3 do + newPos = newPos .. math.Round(pos[i]) + if i < 3 then newPos = newPos .. ", " end + end + return newPos + end + }, + { + txt = "Map", + val = game.GetMap() + }, + { + txt = "Ping", + val = LocalPlayer():Ping() + }, + { + txt = "FPS", + val = function() return math.Round(1 / FrameTime()) end + }, + { + txt = "Size", + val = ScrW() .. "x" .. ScrH() + } + } + + local concatInfo = "" + for k, v in pairs(screenInfo) do + local val = v.val + if type(val) == "function" then val = val() end + concatInfo = concatInfo .. v.txt .. ": " .. val + if k < #screenInfo then concatInfo = concatInfo .. " - " end + end + + draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) +end) \ No newline at end of file diff --git a/lua/gmod_integration/client/cl_report_bug.lua b/lua/gmod_integration/client/cl_report_bug.lua index 7261274..d0ff96c 100644 --- a/lua/gmod_integration/client/cl_report_bug.lua +++ b/lua/gmod_integration/client/cl_report_bug.lua @@ -80,7 +80,6 @@ local captureData = nil hook.Add("PostRender", "gmInte:BugReport:Screenshot", function() if !ScreenshotRequested then return end if contextMenuOpen then return end - ScreenshotRequested = false captureData = { format = "jpeg", x = 0, @@ -91,6 +90,8 @@ hook.Add("PostRender", "gmInte:BugReport:Screenshot", function() } screenCapture = render.Capture(captureData) + ScreenshotRequested = false + gmInte.showScreenshotInfo = false if !file.Exists("gmod_integration/report_bug", "DATA") then file.CreateDir("gmod_integration/report_bug") end if screenCapture then file.Write("gmod_integration/report_bug/" .. screenFileID .. ".jpeg", screenCapture) end end) @@ -213,6 +214,7 @@ function gmInte.openReportBug() if ScreenshotRequested then return end local timerName = "gmInte:BugReport:Screenshot:Open" ScreenshotRequested = true + gmInte.showScreenshotInfo = true screenCapture = nil screenFileID = gmInte.config.id .. "-" .. util.CRC(LocalPlayer():SteamID64() .. "-" .. tostring(os.time())) .. "-" .. tostring(os.time()) timer.Create(timerName, 0.2, 0, function() diff --git a/lua/gmod_integration/client/cl_screenshots.lua b/lua/gmod_integration/client/cl_screenshots.lua index 618d847..c90a37d 100644 --- a/lua/gmod_integration/client/cl_screenshots.lua +++ b/lua/gmod_integration/client/cl_screenshots.lua @@ -2,7 +2,6 @@ local ScreenshotRequested = false local FailAttempts = 0 hook.Add("PostRender", "gmInteScreenshot", function() if !ScreenshotRequested then return end - ScreenshotRequested = false local captureData = { format = "jpeg", x = 0, @@ -13,6 +12,8 @@ hook.Add("PostRender", "gmInteScreenshot", function() } local screenCapture = render.Capture(captureData) + ScreenshotRequested = false + gmInte.showScreenshotInfo = false if !screenCapture then if FailAttempts < 3 then timer.Simple(0.5, function() @@ -40,7 +41,10 @@ hook.Add("PostRender", "gmInteScreenshot", function() end) function gmInte.takeScreenShot() - timer.Simple(0.5, function() ScreenshotRequested = true end) + timer.Simple(0.5, function() + ScreenshotRequested = true + gmInte.showScreenshotInfo = true + end) end concommand.Add("gmi_screen", gmInte.takeScreenShot)