Screenshot: Don't use colon in filename. Use localtime

instead of localtime_r/s. Enable screenshots on Qt build.
This commit is contained in:
BearOso 2024-09-15 10:14:46 -05:00
parent 0c547f3486
commit 9ed6f9d86b
2 changed files with 7 additions and 7 deletions

View File

@ -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)

View File

@ -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(&current_timet, &current_time);
current_time = localtime(&current_timet);
auto screenshot_dir = S9xGetDirectory(SCREENSHOT_DIR);
std::stringstream ss;
ss << screenshot_dir
<< S9xBasenameNoExt(Memory.ROMFilename) << "-"
<< std::put_time(&current_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++)