From 9ed6f9d86b683d3af3ef93e3e397917d75873259 Mon Sep 17 00:00:00 2001 From: BearOso Date: Sun, 15 Sep 2024 10:14:46 -0500 Subject: [PATCH] Screenshot: Don't use colon in filename. Use localtime instead of localtime_r/s. Enable screenshots on Qt build. --- qt/CMakeLists.txt | 7 ++++--- screenshot.cpp | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 4a9d4e86..f0d49187 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -76,7 +76,7 @@ set(SNES9X_CORE_SOURCES ../fscompat.cpp) add_library(snes9x-core ${SNES9X_CORE_SOURCES}) target_include_directories(snes9x-core PRIVATE ../) -target_compile_definitions(snes9x-core PRIVATE ${DEFINES} ZLIB HAVE_STDINT_H ALLOW_CPU_OVERCLOCK) +target_compile_definitions(snes9x-core PRIVATE ${DEFINES} ZLIB HAVE_STDINT_H HAVE_LIBPNG ALLOW_CPU_OVERCLOCK) if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(PREBUILT_QT "${PROJECT_SOURCE_DIR}/../external/qt6-mingw-clang-bin") @@ -100,6 +100,7 @@ list(APPEND INCLUDES ${Qt6Gui_PRIVATE_INCLUDE_DIRS}) find_package(PkgConfig REQUIRED) pkg_check_modules(SDL REQUIRED sdl2) pkg_check_modules(ZLIB REQUIRED zlib) +pkg_check_modules(PNG REQUIRED libpng) list(APPEND INCLUDES ${SDL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) list(APPEND FLAGS ${SDL_COMPILE_FLAGS} ${ZLIB_COMPILE_FLAGS}) @@ -112,7 +113,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") list(APPEND LIBS libstdc++.a) endif() - list(APPEND LIBS libSDL2.a libz.a opengl32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 dinput8) + list(APPEND LIBS libSDL2.a libz.a libpng.a opengl32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 dinput8) list(APPEND DEFINES SDL_MAIN_HANDLED) list(APPEND PLATFORM_SOURCES ../common/video/opengl/wgl_context.cpp @@ -127,7 +128,7 @@ else() endif() list(APPEND INCLUDES ${WAYLAND_INCLUDE_DIRS} ${X11_INCLUDE_DIRS}) - list(APPEND LIBS ${WAYLAND_LIBRARIES} ${X11_LIBRARIES} ${ZLIB_LIBRARIES} ${SDL_LIBRARIES}) + list(APPEND LIBS ${WAYLAND_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} ${ZLIB_LIBRARIES} ${SDL_LIBRARIES}) list(APPEND FLAGS ${WAYLAND_CFLAGS}) pkg_check_modules(PULSEAUDIO libpulse) diff --git a/screenshot.cpp b/screenshot.cpp index a76b8a0c..6e8bfaa9 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -14,7 +14,6 @@ #include "snes9x.h" #include "memmap.h" -#include "display.h" #include "screenshot.h" @@ -29,15 +28,15 @@ bool8 S9xDoScreenshot (int width, int height) png_color_8 sig_bit; int imgwidth, imgheight; - std::tm current_time; + std::tm *current_time; std::time_t current_timet = time(nullptr); - localtime_r(¤t_timet, ¤t_time); + current_time = localtime(¤t_timet); auto screenshot_dir = S9xGetDirectory(SCREENSHOT_DIR); std::stringstream ss; ss << screenshot_dir << S9xBasenameNoExt(Memory.ROMFilename) << "-" - << std::put_time(¤t_time, "%Y-%m-%d-%H:%M:%S"); + << std::put_time(current_time, "%Y-%m-%d-%H-%M-%S"); std::string fname = ss.str() + ".png"; for (int i = 0; i < 1000; i++)