Feat: add screenshot data

This commit is contained in:
Linventif 2024-08-21 18:09:16 +00:00
parent 2542a52051
commit 55f5b99094
3 changed files with 66 additions and 4 deletions

View File

@ -43,3 +43,59 @@ function gmInte.openAdminConfig()
gmInte.SendNet("getConfig")
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)

View File

@ -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()

View File

@ -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)