1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

Merge pull request #612 from metrostroi-repo/#597-fix

#597 fix metrostroi_capture_rt
This commit is contained in:
Sherbanov Kosmik
2025-11-05 00:57:23 +03:00
committed by GitHub

View File

@@ -936,6 +936,11 @@ concommand.Add("metrostroi_capture_rt",function(_,_,args)
local train = LocalPlayer().InMetrostroiTrain
if not IsValid(train) then return end
print("Close menu window for capture RenderTarget train")
hook.Add("HUDPaint","Metrostroi.CaptureRT",function() -- gui.HideGameUI() not working and deprecated
local train = LocalPlayer().InMetrostroiTrain
if IsValid(train) then
local oldRt = render.GetRenderTarget() -- we'll save the old screen and draw on a new one!
file.CreateDir("rt_captures")
for i,v in ipairs(RTs) do
@@ -946,6 +951,8 @@ concommand.Add("metrostroi_capture_rt",function(_,_,args)
local data = render.Capture( { format = "png", quality = 100, x = 0, y = 0, h = RT:Height(), w = RT:Width() } )
print("Request rt_capture "..v..", saved: "..#data.." bytes")
local pictureFile = file.Open("rt_captures/"..train:EntIndex().." "..v.." "..os.date("!%d%m%y_%H%M%S",os.time())..".png", "wb", "DATA" )
pictureFile:Write( data )
pictureFile:Close()
@@ -953,6 +960,9 @@ concommand.Add("metrostroi_capture_rt",function(_,_,args)
end
render.SetRenderTarget( oldRt )
end
hook.Remove("HUDPaint","Metrostroi.CaptureRT")
end)
end)
--------------------------------------------------------------------------------