Skip to content

Commit

Permalink
Screenshot: Don't use colon in filename. Use localtime
Browse files Browse the repository at this point in the history
instead of localtime_r/s. Enable screenshots on Qt build.
  • Loading branch information
bearoso committed Sep 15, 2024
1 parent 0c547f3 commit 9ed6f9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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})

Expand All @@ -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
Expand All @@ -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)
Expand Down
7 changes: 3 additions & 4 deletions screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "snes9x.h"
#include "memmap.h"
#include "display.h"
#include "screenshot.h"


Expand All @@ -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++)
Expand Down

0 comments on commit 9ed6f9d

Please sign in to comment.