mirror of
https://github.com/metrostroi-repo/MetrostroiAddon.git
synced 2026-05-02 00:42:29 +00:00
Update cl_util.lua
This commit is contained in:
@@ -936,23 +936,33 @@ concommand.Add("metrostroi_capture_rt",function(_,_,args)
|
|||||||
local train = LocalPlayer().InMetrostroiTrain
|
local train = LocalPlayer().InMetrostroiTrain
|
||||||
if not IsValid(train) then return end
|
if not IsValid(train) then return end
|
||||||
|
|
||||||
local oldRt = render.GetRenderTarget() -- we'll save the old screen and draw on a new one!
|
print("Close menu window, for capture RenderTarget train")
|
||||||
file.CreateDir("rt_captures")
|
|
||||||
for i,v in ipairs(RTs) do
|
|
||||||
local RT = train[v]
|
|
||||||
if RT and type(RT) == "ITexture" then
|
|
||||||
|
|
||||||
render.SetRenderTarget( train[v] )
|
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
|
||||||
|
local RT = train[v]
|
||||||
|
if RT and type(RT) == "ITexture" then
|
||||||
|
|
||||||
local data = render.Capture( { format = "png", quality = 100, x = 0, y = 0, h = RT:Height(), w = RT:Width() } )
|
render.SetRenderTarget( train[v] )
|
||||||
|
|
||||||
local pictureFile = file.Open("rt_captures/"..train:EntIndex().." "..v.." "..os.date("!%d%m%y_%H%M%S",os.time())..".png", "wb", "DATA" )
|
local data = render.Capture( { format = "png", quality = 100, x = 0, y = 0, h = RT:Height(), w = RT:Width() } )
|
||||||
pictureFile:Write( data )
|
|
||||||
pictureFile:Close()
|
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()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
render.SetRenderTarget( oldRt )
|
||||||
end
|
end
|
||||||
end
|
hook.Remove("HUDPaint","Metrostroi.CaptureRT")
|
||||||
|
end)
|
||||||
render.SetRenderTarget( oldRt )
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user