mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 22:37:34 +00:00
Feat: add screenshot data
This commit is contained in:
parent
2542a52051
commit
55f5b99094
|
@ -42,4 +42,60 @@ function gmInte.openAdminConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
gmInte.SendNet("getConfig")
|
gmInte.SendNet("getConfig")
|
||||||
end
|
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)
|
|
@ -80,7 +80,6 @@ local captureData = nil
|
||||||
hook.Add("PostRender", "gmInte:BugReport:Screenshot", function()
|
hook.Add("PostRender", "gmInte:BugReport:Screenshot", function()
|
||||||
if !ScreenshotRequested then return end
|
if !ScreenshotRequested then return end
|
||||||
if contextMenuOpen then return end
|
if contextMenuOpen then return end
|
||||||
ScreenshotRequested = false
|
|
||||||
captureData = {
|
captureData = {
|
||||||
format = "jpeg",
|
format = "jpeg",
|
||||||
x = 0,
|
x = 0,
|
||||||
|
@ -91,6 +90,8 @@ hook.Add("PostRender", "gmInte:BugReport:Screenshot", function()
|
||||||
}
|
}
|
||||||
|
|
||||||
screenCapture = render.Capture(captureData)
|
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 !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
|
if screenCapture then file.Write("gmod_integration/report_bug/" .. screenFileID .. ".jpeg", screenCapture) end
|
||||||
end)
|
end)
|
||||||
|
@ -213,6 +214,7 @@ function gmInte.openReportBug()
|
||||||
if ScreenshotRequested then return end
|
if ScreenshotRequested then return end
|
||||||
local timerName = "gmInte:BugReport:Screenshot:Open"
|
local timerName = "gmInte:BugReport:Screenshot:Open"
|
||||||
ScreenshotRequested = true
|
ScreenshotRequested = true
|
||||||
|
gmInte.showScreenshotInfo = true
|
||||||
screenCapture = nil
|
screenCapture = nil
|
||||||
screenFileID = gmInte.config.id .. "-" .. util.CRC(LocalPlayer():SteamID64() .. "-" .. tostring(os.time())) .. "-" .. tostring(os.time())
|
screenFileID = gmInte.config.id .. "-" .. util.CRC(LocalPlayer():SteamID64() .. "-" .. tostring(os.time())) .. "-" .. tostring(os.time())
|
||||||
timer.Create(timerName, 0.2, 0, function()
|
timer.Create(timerName, 0.2, 0, function()
|
||||||
|
|
|
@ -2,7 +2,6 @@ local ScreenshotRequested = false
|
||||||
local FailAttempts = 0
|
local FailAttempts = 0
|
||||||
hook.Add("PostRender", "gmInteScreenshot", function()
|
hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
if !ScreenshotRequested then return end
|
if !ScreenshotRequested then return end
|
||||||
ScreenshotRequested = false
|
|
||||||
local captureData = {
|
local captureData = {
|
||||||
format = "jpeg",
|
format = "jpeg",
|
||||||
x = 0,
|
x = 0,
|
||||||
|
@ -13,6 +12,8 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
}
|
}
|
||||||
|
|
||||||
local screenCapture = render.Capture(captureData)
|
local screenCapture = render.Capture(captureData)
|
||||||
|
ScreenshotRequested = false
|
||||||
|
gmInte.showScreenshotInfo = false
|
||||||
if !screenCapture then
|
if !screenCapture then
|
||||||
if FailAttempts < 3 then
|
if FailAttempts < 3 then
|
||||||
timer.Simple(0.5, function()
|
timer.Simple(0.5, function()
|
||||||
|
@ -40,7 +41,10 @@ hook.Add("PostRender", "gmInteScreenshot", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function gmInte.takeScreenShot()
|
function gmInte.takeScreenShot()
|
||||||
timer.Simple(0.5, function() ScreenshotRequested = true end)
|
timer.Simple(0.5, function()
|
||||||
|
ScreenshotRequested = true
|
||||||
|
gmInte.showScreenshotInfo = true
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
concommand.Add("gmi_screen", gmInte.takeScreenShot)
|
concommand.Add("gmi_screen", gmInte.takeScreenShot)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user