mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
ensure that the game operates on UTF-8 on Windows
Should fix issues with Unicode filenames.
This commit is contained in:
parent
9c39090890
commit
3586f49762
6 changed files with 51 additions and 0 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "src/3rdparty/cimgui"]
|
||||
path = src/3rdparty/cimgui
|
||||
url = https://gitlab.com/dosowisko.net/cimgui.git
|
||||
[submodule "src/3rdparty/dlfcn-win32"]
|
||||
path = src/3rdparty/dlfcn-win32
|
||||
url = https://gitlab.com/dosowisko.net/dlfcn-win32.git
|
||||
|
|
|
@ -17,6 +17,12 @@ if (NOT LIBSUPERDERPY_CONFIG_INCLUDED)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98")
|
||||
endif(MAEMO5)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mwindows -municode")
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
option(LIBSUPERDERPY_DLFCN "Use built-in dlfcn with Unicode support" ON)
|
||||
endif(WIN32)
|
||||
|
||||
if(ANDROID)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
endif(ANDROID)
|
||||
|
|
1
src/3rdparty/dlfcn-win32
vendored
Submodule
1
src/3rdparty/dlfcn-win32
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 8191c43de39def345e727b76d8c1abd0ffb0c306
|
|
@ -31,6 +31,12 @@ else (LIBSUPERDERPY_STATIC)
|
|||
add_library("libsuperderpy" SHARED ${SRC_LIST})
|
||||
endif (LIBSUPERDERPY_STATIC)
|
||||
|
||||
if (WIN32 AND LIBSUPERDERPY_DLFCN)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE STRING "" FORCE)
|
||||
add_subdirectory(3rdparty/dlfcn-win32 EXCLUDE_FROM_ALL)
|
||||
set_property(TARGET "dl" PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif(WIN32 AND LIBSUPERDERPY_DLFCN)
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy" PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries("libsuperderpy" ${ALLEGRO5_LIBRARIES} ${ALLEGRO5_FONT_LIBRARIES} ${ALLEGRO5_TTF_LIBRARIES} ${ALLEGRO5_PRIMITIVES_LIBRARIES} ${ALLEGRO5_AUDIO_LIBRARIES} ${ALLEGRO5_ACODEC_LIBRARIES} ${ALLEGRO5_VIDEO_LIBRARIES} ${ALLEGRO5_IMAGE_LIBRARIES} m dl)
|
||||
|
@ -39,6 +45,10 @@ if (LIBSUPERDERPY_IMGUI)
|
|||
target_link_libraries("libsuperderpy" cimgui)
|
||||
endif (LIBSUPERDERPY_IMGUI)
|
||||
|
||||
if (WIN32 AND LIBSUPERDERPY_DLFCN)
|
||||
target_link_libraries("libsuperderpy" psapi)
|
||||
endif (WIN32 AND LIBSUPERDERPY_DLFCN)
|
||||
|
||||
if (ANDROID)
|
||||
target_link_libraries("libsuperderpy" log)
|
||||
endif (ANDROID)
|
||||
|
|
|
@ -505,7 +505,17 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game* game) {
|
|||
#ifdef ALLEGRO_MACOSX
|
||||
chdir(game->_priv.cwd);
|
||||
#endif
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
wchar_t* wargv[game->_priv.argc];
|
||||
for (int i = 0; i < game->_priv.argc; i++) {
|
||||
size_t size = MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, NULL, 0);
|
||||
wargv[i] = alloca(sizeof(wchar_t) * size);
|
||||
MultiByteToWideChar(CP_UTF8, 0, argv[i], -1, wargv[i], size);
|
||||
}
|
||||
_wexecv(wargv[0], (const wchar_t* const*)wargv);
|
||||
#else
|
||||
execv(argv[0], argv);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -29,6 +29,12 @@ struct GamestateResources;
|
|||
#define LIBSUPERDERPY_DATA_TYPE void
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_acodec.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
@ -79,6 +85,21 @@ struct GamestateResources;
|
|||
|
||||
#define LIBSUPERDERPY_BITMAP_HASHMAP_BUCKETS 16
|
||||
|
||||
#if defined(ALLEGRO_WINDOWS) && !defined(LIBSUPERDERPY_NO_MAIN_MANGLING)
|
||||
int _libsuperderpy_main(int argc, char** argv);
|
||||
#define main(a, b) \
|
||||
wmain(int argc, wchar_t** wargv) { \
|
||||
char* argv[argc]; \
|
||||
for (int i = 0; i < argc; i++) { \
|
||||
size_t size = WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL); \
|
||||
argv[i] = alloca(sizeof(char) * size); \
|
||||
WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], size, NULL, NULL); \
|
||||
} \
|
||||
return _libsuperderpy_main(argc, argv); \
|
||||
} \
|
||||
int _libsuperderpy_main(a, b)
|
||||
#endif
|
||||
|
||||
struct Viewport {
|
||||
int width; /*!< Width of the drawing canvas. */
|
||||
int height; /*!< Height of the drawing canvas. */
|
||||
|
|
Loading…
Reference in a new issue