WIP. build under Win32 without SDL

This commit is contained in:
Thomas Bernard 2018-05-31 17:29:29 +02:00
parent 4d86b8a0c1
commit 3e4f3d0313
12 changed files with 54 additions and 24 deletions

View File

@ -52,7 +52,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\lpng1634;..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -66,7 +66,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NOTTF;__ENABLE_LUA__;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4244</DisableSpecificWarnings>
<AdditionalIncludeDirectories>..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\lpng1634;..\..\..\..\lua\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -1406,8 +1406,10 @@ void Main_handler(void)
}
else
{
#if defined(USE_SDL) || defined(USE_SDL2)
// Removed all SDL_Delay() timing here: relying on Get_input()
SDL_Delay(10);
#endif
}
// Gestion de la souris

View File

@ -34,7 +34,7 @@
#include <sys/types.h>
#elif defined (__MINT__)
#include <mint/sysbind.h>
#elif defined(__WIN32__)
#elif defined(WIN32)
#include <windows.h>
#include <commdlg.h>
#endif
@ -92,15 +92,19 @@
byte Native_filesel(byte load)
{
//load = load;
#ifdef __WIN32__
#if WIN32
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
SDL_SysWMinfo wminfo;
HWND hwnd;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version);
SDL_GetWMInfo(&wminfo);
hwnd = wminfo.window;
#else
hwnd = GetActiveWindow();
#endif
ZeroMemory(&ofn, sizeof(ofn));
@ -459,7 +463,7 @@ static void Read_dir_callback(void * pdata, const char *file_name, const word *u
// unreliable on non-physical drives :
// Sometimes it's missing, sometimes it's present even at root...
// We skip it here and add a specific check after the loop
#if defined(__WIN32__)
#if defined(WIN32)
if (!strcmp(file_name, PARENT_DIR))
return;
#endif
@ -564,7 +568,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
Add_element_to_list(list, PARENT_DIR, Format_filename(PARENT_DIR,19,1), 1, ICON_NONE);
list->Nb_directories ++;
#elif defined (__WIN32__)
#elif defined (WIN32)
// Windows :
if (((current_path[0]>='a'&&current_path[0]<='z')||(current_path[0]>='A'&&current_path[0]<='Z')) &&
current_path[1]==':' &&
@ -674,7 +678,7 @@ void Read_list_of_drives(T_Fileselector *list, byte name_length)
UnLockDosList( LDF_VOLUMES | LDF_ASSIGNS | LDF_READ );
}
}
#elif defined (__WIN32__)
#elif defined (WIN32)
{
char drive_name[]="A:\\";
int drive_bits = GetLogicalDrives();

View File

@ -1135,7 +1135,9 @@ void Fill_general(byte fill_color)
if (! (Permanent_draw_count&7))
{
dword now = GFX2_GetTicks();
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_PumpEvents();
#endif
if (now>= Permanent_draw_next_refresh)
{
Permanent_draw_next_refresh = now+100;

View File

@ -25,7 +25,7 @@
// Signal handler: I activate it for the two platforms who certainly
// support them. Feel free to check with others.
#if defined(__WIN32__) || defined(__linux__)
#if defined(WIN32) || defined(__linux__)
#define GRAFX2_CATCHES_SIGNALS
#endif
@ -49,7 +49,7 @@
#if defined(USE_SDL)
#include <SDL_byteorder.h>
#endif
#if defined(__WIN32__)
#if defined(WIN32)
#include <windows.h> // GetLogicalDrives(), GetDriveType(), DRIVE_*
#endif
#if !defined(__GP2X__) && defined(USE_SDL)
@ -2872,7 +2872,10 @@ void Set_config_defaults(void)
#ifdef GRAFX2_CATCHES_SIGNALS
#if defined(__WIN32__)
#if defined(WIN32)
#if defined(_MSC_VER)
typedef void (*__p_sig_fn_t)(int);
#endif
#define SIGHANDLER_T __p_sig_fn_t
#elif defined(__macosx__)
typedef void (*sig_t) (int);
@ -3096,7 +3099,9 @@ void Define_icon(void)
LPVOID lpResIcon32;
HGLOBAL hMem;
WORD nID;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo info;
#endif
hInstance = (HINSTANCE)GetModuleHandle(NULL);
if (hInstance==NULL)
@ -3118,9 +3123,11 @@ void Define_icon(void)
if (lpResIconDir==NULL)
break;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);
#endif
//
// 16x16
//
@ -3152,9 +3159,13 @@ void Define_icon(void)
16, 16, LR_DEFAULTCOLOR);
if (hicon==NULL)
break;
// Set it
#if defined(USE_SDL) || defined(USE_SDL2)
SetClassLongPtr(info.window, GCL_HICONSM, (LONG_PTR)hicon);
#else
// TODO
#endif
//
@ -3190,7 +3201,11 @@ void Define_icon(void)
break;
// Set it
#if defined(USE_SDL) || defined(USE_SDL2)
SetClassLongPtr(info.window, GCL_HICON, (LONG_PTR)hicon);
#else
// TODO
#endif
// Success

View File

@ -26,7 +26,7 @@
#include <SDL_syswm.h>
#endif
#ifdef __WIN32__
#ifdef WIN32
#include <windows.h>
#include <shellapi.h>
#endif

View File

@ -598,7 +598,7 @@ void Get_full_filename(char * output_name, const char * file_name, const char *
}
/// Lock file used to prevent several instances of grafx2 from harming each others' backups
#ifdef __WIN32__
#ifdef WIN32
HANDLE Lock_file_handle = INVALID_HANDLE_VALUE;
#else
int Lock_file_handle = -1;
@ -618,7 +618,7 @@ byte Create_lock_file(const char *file_directory)
#endif
strcat(lock_filename,"gfx2.lck");
#ifdef __WIN32__
#ifdef WIN32
// Windowzy method for creating a lock file
Lock_file_handle = CreateFileA(
lock_filename,
@ -655,7 +655,7 @@ void Release_lock_file(const char *file_directory)
{
char lock_filename[MAX_PATH_CHARACTERS];
#ifdef __WIN32__
#ifdef WIN32
if (Lock_file_handle != INVALID_HANDLE_VALUE)
{
CloseHandle(Lock_file_handle);

View File

@ -79,7 +79,7 @@ void Extract_path(char *dest, const char *source);
/// Finds the rightmost path separator in a full filename. Used to separate directory from file.
char * Find_last_separator(const char * str);
#if defined(__WIN32__)
#if defined(WIN32)
#define PATH_SEPARATOR "\\"
#elif defined(__MINT__)
#define PATH_SEPARATOR "\\"

View File

@ -715,7 +715,7 @@ void Zoom_a_line(byte* original_line, byte* zoomed_line,
/*############################################################################*/
#if defined(__WIN32__)
#if defined(WIN32)
#include <windows.h>
#elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__OpenBSD__)
@ -755,7 +755,7 @@ unsigned long Memory_free(void)
// If Grafx2 thinks the memory is full, weird things may happen. And if memory
// ever becomes full and you're still saying there are 10MB free here, the
// program will crash without saving any picture backup ! You've been warned...
#if defined(__WIN32__)
#if defined(WIN32)
MEMORYSTATUS mstt;
mstt.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&mstt);

View File

@ -193,7 +193,7 @@ static int Valid_character(word c, int input_type)
// d'autres poseront des problèmes au shell, alors on évite.
// Sous Windows : c'est moins grave car le fopen() échouerait de toutes façons.
// AmigaOS4: Pas de ':' car utilisé pour les volumes.
#if defined(__WIN32__)
#if defined(WIN32)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':', '\\'};
#elif defined (__amigaos4__) || defined(__AROS__)
char forbidden_char[] = {'/', '|', '?', '*', '<', '>', ':'};
@ -305,8 +305,9 @@ void Init_virtual_keyboard(word y_pos, word keyboard_width, word keyboard_height
// TODO X11 and others
static char* getClipboard(word * * unicode)
{
#ifdef __WIN32__
#ifdef WIN32
char* dst = NULL;
#if defined(USE_SDL) || defined(USE_SDL2)
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
@ -314,6 +315,10 @@ static char* getClipboard(word * * unicode)
if ( SDL_GetWMInfo(&info) )
{
if (OpenClipboard(info.window) )
#else
{
if (OpenClipboard(GetActiveWindow()))
#endif
{
HANDLE hMem;
if ( IsClipboardFormatAvailable(CF_TEXT) )

View File

@ -69,7 +69,7 @@
if (chdir(path)) {
if (errno == ENOTDIR) {
#if defined(__WIN32__) || defined(__MORPHOS__) || defined(__amigaos__)
#if defined(WIN32) || defined(__MORPHOS__) || defined(__amigaos__)
// No symbolic links and no readlink()
l = -1;
#else

View File

@ -295,7 +295,7 @@ void Init_text(void)
snprintf(directory_name, sizeof(directory_name), "%s%s", Config_directory, "/fonts");
For_each_file(directory_name, Add_font);
#if defined(__WIN32__)
#if defined(WIN32)
// Parcours du répertoire systeme windows "fonts"
#ifndef NOTTF
{
@ -709,6 +709,8 @@ byte *Render_text(const char *str, int font_number, int size, int antialias, int
{
#if defined(USE_SDL) || defined(USE_SDL2)
return Render_text_SFont(str, font_number, width, height, palette);
#else
return NULL;
#endif
}
}