From 10a0a34b1be088d6c578e9da8e56925579ff1c45 Mon Sep 17 00:00:00 2001 From: dolphin6k Date: Sat, 28 Oct 2023 17:55:38 +0900 Subject: [PATCH] Output Version of Tux Paint and Windows This enables to know the user's environment easily. --- Makefile | 8 ++++++- src/tuxpaint.c | 7 +++++++ src/win32_version.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/win32_version.c diff --git a/Makefile b/Makefile index 6f0697c37..2dc0dead2 100644 --- a/Makefile +++ b/Makefile @@ -166,7 +166,7 @@ macos_BUNDLE:=./TuxPaint.app ios_BUNDLE:=./TuxPaint-$(SDK).app BUNDLE:=$($(OS)_BUNDLE) -windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o obj/win32_trash.o +windows_ARCH_LIBS:=obj/win32_print.o obj/resource.o obj/win32_trash.o obj/win32_version.o macos_ARCH_LIBS:=src/macos_print.m obj/macos.o ios_ARCH_LIBS:=src/ios_print.m obj/ios.o beos_ARCH_LIBS:=obj/BeOS_print.o @@ -1363,6 +1363,12 @@ obj/win32_trash.o: src/win32_trash.c src/debug.h @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) $(ARCH_DEFS) \ -c src/win32_trash.c -o obj/win32_trash.o +obj/win32_version.o: src/win32_version.c src/debug.h + @echo + @echo "...Compiling win32 version support..." + @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) $(ARCH_DEFS) \ + -c src/win32_version.c -o obj/win32_version.o + obj/postscript_print.o: src/postscript_print.c \ src/postscript_print.h src/debug.h @echo diff --git a/src/tuxpaint.c b/src/tuxpaint.c index d8dab28c4..a25607d0e 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -390,6 +390,7 @@ typedef struct safer_dirent #define wcstombs(tok, wtok, size) WideCharToMultiByte(CP_UTF8,0,wtok,-1,tok,size,NULL,NULL) extern int win32_trash(const char *path); +extern void win32_print_version(void); #undef iswprint int iswprint(wchar_t wc) @@ -30579,6 +30580,12 @@ int main(int argc, char *argv[]) } #endif +#ifdef WIN32 + printf("Tux Paint Version " VER_VERSION " (" VER_DATE ")\n"); + printf("Running on "); + win32_print_version(); +#endif + claim_to_be_ready(); mainloop(); diff --git a/src/win32_version.c b/src/win32_version.c new file mode 100644 index 000000000..064b2e6e8 --- /dev/null +++ b/src/win32_version.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include "debug.h" + +void win32_print_version(void); + +void win32_print_version(void) +{ + char *verStr; + unsigned int Version = 0; + unsigned int Build = 0; + + Version = GetVersion(); + if (Version < 0x80000000) + Build = (DWORD)(HIWORD(Version)); + + if (IsWindows10OrGreater()) { + if (Build < 22000){ + verStr = strdup("Windows 10"); + }else{ + verStr = strdup("Windows 11"); + } + }else if (IsWindows8Point1OrGreater()){ + verStr = strdup("Windows 8.1"); + }else if (IsWindows8OrGreater()){ + verStr = strdup("Windows 8"); + }else if (IsWindows7SP1OrGreater()){ + verStr = strdup("Windows 7 Service Pack 1"); + }else if (IsWindows7OrGreater()){ + verStr = strdup("Windows 7"); + }else if (IsWindowsVistaSP2OrGreater()){ + verStr = strdup("Windows Vista Service Pack 2"); + }else if (IsWindowsVistaSP1OrGreater()){ + verStr = strdup("Windows Vista Service Pack 1"); + }else if (IsWindowsVistaOrGreater()){ + verStr = strdup("Windows Vista"); + }else{ + verStr = strdup("unknown"); + } + + printf ("Microsoft %s", verStr); + + if (IsWindowsServer()){ + printf(" Server"); + } + + if (Version < 0x80000000){ + printf(" (Build %d)\n", Build); + } +}