From 41143af0e15d2031eabc1a0ce631ca2514248bf0 Mon Sep 17 00:00:00 2001 From: Ilya Krasnow Date: Wed, 5 Nov 2025 00:51:56 +0300 Subject: [PATCH 1/2] Update cl_util.lua --- lua/metrostroi/cl_util.lua | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/lua/metrostroi/cl_util.lua b/lua/metrostroi/cl_util.lua index 79c0490..a11f71a 100644 --- a/lua/metrostroi/cl_util.lua +++ b/lua/metrostroi/cl_util.lua @@ -936,23 +936,33 @@ concommand.Add("metrostroi_capture_rt",function(_,_,args) local train = LocalPlayer().InMetrostroiTrain if not IsValid(train) then return end - 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 + print("Close menu window, for capture RenderTarget train") - 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" ) - pictureFile:Write( data ) - pictureFile:Close() + 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() + end + end + + render.SetRenderTarget( oldRt ) end - end - - render.SetRenderTarget( oldRt ) + hook.Remove("HUDPaint","Metrostroi.CaptureRT") + end) end) -------------------------------------------------------------------------------- @@ -1007,4 +1017,4 @@ function Metrostroi.MakeSpriteTexture(path,isSprite) Metrostroi.SpriteCache2[path] = CreateMaterial(path..":spriteug","UnlitGeneric",matUnlit) return Metrostroi.SpriteCache2[path] end -end \ No newline at end of file +end From fcbe4bd4376c236496fa8c71847be3ab2de6b2fa Mon Sep 17 00:00:00 2001 From: Ilya Krasnow Date: Wed, 5 Nov 2025 00:56:30 +0300 Subject: [PATCH 2/2] Big update --- lua/metrostroi/cl_util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/metrostroi/cl_util.lua b/lua/metrostroi/cl_util.lua index a11f71a..943977c 100644 --- a/lua/metrostroi/cl_util.lua +++ b/lua/metrostroi/cl_util.lua @@ -936,7 +936,7 @@ 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") + print("Close menu window for capture RenderTarget train") hook.Add("HUDPaint","Metrostroi.CaptureRT",function() -- gui.HideGameUI() not working and deprecated local train = LocalPlayer().InMetrostroiTrain