From dcd27af126da1388ac89979cf34b657cd240c262 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Mon, 17 Jan 2022 20:29:32 +0300 Subject: [PATCH] render: move screenshorts into render --- src/game/g_game.pas | 43 ++++++++++++++---------------------- src/game/opengl/r_render.pas | 24 +++++++++++++++++--- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 70321dd..11defae 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -1,4 +1,4 @@ -(* Copyright (C) Doom 2D: Forever Developers + (* Copyright (C) Doom 2D: Forever Developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -6116,33 +6116,24 @@ begin end; procedure g_TakeScreenShot(Filename: string = ''); - var s: TStream; t: TDateTime; dir, date, name: String; + var t: TDateTime; dir, date, name: String; begin - if e_NoGraphics then Exit; - try - dir := e_GetWriteableDir(ScreenshotDirs); + if e_NoGraphics then + Exit; - if Filename = '' then - begin - t := Now; - DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t); - Filename := 'screenshot-' + date; - end; - - name := e_CatPath(dir, Filename + '.png'); - s := createDiskFile(name); - try - e_MakeScreenshot(s, gWinSizeX, gWinSizeY); - s.Free; - g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name])) - except - g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name])); - s.Free; - DeleteFile(name) - end - except - g_Console_Add('oh shit, i can''t create screenshot!') - end + dir := e_GetWriteableDir(ScreenshotDirs); + if Filename = '' then + begin + t := Now; + DateTimeToString(date, 'yyyy-mm-dd-hh-nn-ss', t); + Filename := 'screenshot-' + date; + end; + + name := e_CatPath(dir, Filename + '.png'); + if r_Render_WriteScreenShot(name) then + g_Console_Add(Format(_lc[I_CONSOLE_SCREENSHOT], [name])) + else + g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [name])); end; procedure g_Game_InGameMenu(Show: Boolean); diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 90bda3b..3535a2d 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -26,18 +26,19 @@ interface procedure r_Render_LoadTextures; procedure r_Render_FreeTextures; - procedure r_Render_Resize (w, h: Integer); - procedure r_Render_Update; + procedure r_Render_Resize (w, h: Integer); procedure r_Render_Apply; + function r_Render_WriteScreenShot (filename: String): Boolean; + implementation uses {$INCLUDE ../../nogl/noGLuses.inc} SysUtils, Classes, Math, - e_log, g_system, + e_log, g_system, utils, g_game, g_options, g_console, r_window, r_graphics, r_console, r_playermodel, r_textures, r_animations, r_weapons, r_items, r_gfx, r_monsters, r_map, r_player, r_game @@ -178,4 +179,21 @@ implementation sys_EnableVSync(gVSync) end; + function r_Render_WriteScreenShot (filename: String): Boolean; + var s: TStream; + begin + Result := False; + try + s := CreateDiskFile(filename); + try + e_MakeScreenshot(s, gWinSizeX, gWinSizeX); + Result := True; + except + DeleteFile(filename) + end; + s.Free; + finally + end + end; + end. -- 2.29.2