From 4d46bafb95781d6b4219a6d0eb13d991d4c5d7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20R=2E=20Pietraszczyk?= Date: Thu, 26 Sep 2024 11:11:34 +0200 Subject: Added wrapper for Windows --- desktop/samegame/Changelog.txt | 1 + desktop/samegame/MINGW32/Makefile.mingw32 | 36 +++++++++++++ desktop/samegame/MINGW32/config.txt | 1 + desktop/samegame/MINGW32/samegame.rc | 26 +++++++++ desktop/samegame/MINGW32/wrapper.c | 86 ++++++++++++++++++++++++++++++ desktop/samegame/res/icon.ico | Bin 0 -> 2549 bytes 6 files changed, 150 insertions(+) create mode 100644 desktop/samegame/MINGW32/Makefile.mingw32 create mode 100755 desktop/samegame/MINGW32/config.txt create mode 100755 desktop/samegame/MINGW32/samegame.rc create mode 100755 desktop/samegame/MINGW32/wrapper.c create mode 100644 desktop/samegame/res/icon.ico diff --git a/desktop/samegame/Changelog.txt b/desktop/samegame/Changelog.txt index ce437bf..fdef665 100644 --- a/desktop/samegame/Changelog.txt +++ b/desktop/samegame/Changelog.txt @@ -1,3 +1,4 @@ +0.240417-4 - Dodanie wrapper dla Windows 0.240417-2 - Pakietowanie 0.240417-1 - Poprawki w naliczaniu punktacji z promowaaniem wyższych poziomów 0.240417-0 - Dodalem punktacje oraz poziomy diff --git a/desktop/samegame/MINGW32/Makefile.mingw32 b/desktop/samegame/MINGW32/Makefile.mingw32 new file mode 100644 index 0000000..a80fef0 --- /dev/null +++ b/desktop/samegame/MINGW32/Makefile.mingw32 @@ -0,0 +1,36 @@ +CPP = i686-w64-mingw32-g++ +CC = i686-w64-mingw32-gcc + +WINDRES = i686-w64-mingw32-windres +RES = +OBJ = wrapper.o $(RES) +LINKOBJ = wrapper.o $(RES) +#LIBS = -L"/lib" -lsdl -lsdl_ttf -mwindows +LIBS = -static-libgcc +INCS = +CXXINCS = +BIN = samegame.exe +CXXFLAGS = $(CXXINCS) -g +CFLAGS = $(INCS) +RM = rm + +.PHONY: all all-before all-after clean clean-custom + +all: all-before samegame.exe all-after + + +clean: clean-custom + ${RM} $(OBJ) + ${RM} $(BIN) + + ${RM} icon.o + + +$(BIN): $(OBJ) + $(WINDRES) samegame.rc -O coff -o icon.o + $(CC) $(LINKOBJ) -o "samegame.exe" $(LIBS) -mwindows icon.o + +wrapper.o: wrapper.c + $(CC) -c wrapper.c -o wrapper.o $(CFLAGS) -DNO_STDIO_REDIRECT + + diff --git a/desktop/samegame/MINGW32/config.txt b/desktop/samegame/MINGW32/config.txt new file mode 100755 index 0000000..5e3e33e --- /dev/null +++ b/desktop/samegame/MINGW32/config.txt @@ -0,0 +1 @@ +.\jre\bin\javaw.exe -jar SameGame.jar diff --git a/desktop/samegame/MINGW32/samegame.rc b/desktop/samegame/MINGW32/samegame.rc new file mode 100755 index 0000000..16920cb --- /dev/null +++ b/desktop/samegame/MINGW32/samegame.rc @@ -0,0 +1,26 @@ +id ICON "../res/icon.ico" +1 VERSIONINFO +FILEVERSION 0,240417,1,1 +PRODUCTVERSION 0,240417,1,1 +FILEOS 0x4 +FILETYPE 0x1 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Przemyslaw R. Pietraszczyk" + VALUE "FileDescription", "My implementation Same Game" + VALUE "FileVersion", "0, 240417, 1, 1" + VALUE "InternalName", "Win32App" + VALUE "LegalCopyright", "0169 Pietraszczyk" + VALUE "OriginalFilename", "samegame.exe" + VALUE "ProductName", "Same Game" + VALUE "ProductVersion", "0,240417, 1, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0809, 1200 + END +END diff --git a/desktop/samegame/MINGW32/wrapper.c b/desktop/samegame/MINGW32/wrapper.c new file mode 100755 index 0000000..83e260a --- /dev/null +++ b/desktop/samegame/MINGW32/wrapper.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include // exit +#include // sleep access + +char * file_exist(){ + char * name = (char *)".\\config.txt"; + //char *file = current(name); + char *file = name; + + if (access(file, F_OK)==0){ + printf("PLIK istnieje %s\n",file); + //free(file); + return file; + } + printf("PLIK nie istnieje %s\n",file); + //free(file); + return NULL; +} + + + + +void main( int argc, TCHAR *argv[] ) +{ + STARTUPINFO si; + PROCESS_INFORMATION pi; + + char * file = file_exist(); + char bufor1[128]; + char bufor2[128]; + char bufor3[128]; + char run[384]; + + if (!file) exit(1); + + FILE * f = fopen(file, "r"); + fscanf(f, "%s %s %s", bufor1,bufor2,bufor3); + fclose(f); + strcpy(run, bufor1); + strcat(run, " "); + strcat(run, bufor2); + strcat(run, " "); + strcat(run, bufor3); + printf("Uruchamiam %s \n",run); + //free(file); + + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + //if( argc != 2 ) + //{ + // printf("Usage: %s [cmdline]\n", argv[0]); + // return; + //} + + // Start the child process. + if( !CreateProcess( NULL, // No module name (use command line) + run, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi ) // Pointer to PROCESS_INFORMATION structure + ) { + printf ("Create Success\n"); + } + else + { + printf( "CreateProcess failed (%d).\n", GetLastError() ); + return; + } + + // Wait until child process exits. + WaitForSingleObject( pi.hProcess, INFINITE ); + + // Close process and thread handles. + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); +} diff --git a/desktop/samegame/res/icon.ico b/desktop/samegame/res/icon.ico new file mode 100644 index 0000000..e241233 Binary files /dev/null and b/desktop/samegame/res/icon.ico differ -- cgit v1.2.3