diff --git a/REDALERT/GADGET.CPP b/REDALERT/GADGET.CPP index d288a25..a2c4147 100644 --- a/REDALERT/GADGET.CPP +++ b/REDALERT/GADGET.CPP @@ -55,6 +55,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "function.h" +#include /* @@ -471,7 +472,6 @@ KeyNumType GadgetClass::Input(void) { int mousex, mousey; KeyNumType key; - unsigned flags; int forced = false; /* @@ -530,33 +530,50 @@ KeyNumType GadgetClass::Input(void) ** know the position of the mouse at the exact instant when the click occurred ** rather the the mouse position at the time we get around to this function. */ - if (((key&0xFF) == KN_LMOUSE) || ((key&0xFF) == KN_RMOUSE)) { - mousex = Keyboard->MouseQX; - mousey = Keyboard->MouseQY; - } else { - mousex = Get_Mouse_X(); - mousey = Get_Mouse_Y(); +// jmarshall + static int flags = 0; + SDL_GetMouseState(&mousex, &mousey); + + if (flags == LEFTRELEASE || flags == RIGHTRELEASE) + flags = 0; + + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) + { + case SDL_MOUSEBUTTONDOWN: + if (event.button.button == SDL_BUTTON_LEFT) { + flags = LEFTPRESS; + } + break; + + case SDL_MOUSEBUTTONUP: + if (event.button.button == SDL_BUTTON_LEFT) { + flags = LEFTRELEASE; + } + break; + } } +// jmarshall end /* ** Set the mouse button state flags. These will be passed to the individual ** buttons so that they can determine what action to perform (if any). - */ - flags = 0; - if (key) { - if (key == KN_LMOUSE) { - flags |= LEFTPRESS; - } - if (key == KN_RMOUSE) { - flags |= RIGHTPRESS; - } - if (key == (KN_LMOUSE | KN_RLSE_BIT)) { - flags |= LEFTRELEASE; - } - if (key == (KN_RMOUSE | KN_RLSE_BIT)) { - flags |= RIGHTRELEASE; - } - } + */ + //if (key) { + // if (key == KN_LMOUSE) { + // flags |= LEFTPRESS; + // } + // if (key == KN_RMOUSE) { + // flags |= RIGHTPRESS; + // } + // if (key == (KN_LMOUSE | KN_RLSE_BIT)) { + // flags |= LEFTRELEASE; + // } + // if (key == (KN_RMOUSE | KN_RLSE_BIT)) { + // flags |= RIGHTRELEASE; + // } + //} /* ** If the mouse wasn't responsible for this key code, then it must be from diff --git a/REDALERT/INIT.CPP b/REDALERT/INIT.CPP index 97ad653..d20db97 100644 --- a/REDALERT/INIT.CPP +++ b/REDALERT/INIT.CPP @@ -3381,7 +3381,7 @@ static void Init_Mouse(void) ** to set one of our own. */ #ifdef WIN32 - ShowCursor(false); +// ShowCursor(false); #endif if (MouseInstalled) { void const * temp_mouse_shapes = MFCD::Retrieve("MOUSE.SHP"); diff --git a/REDALERT/MENUS.CPP b/REDALERT/MENUS.CPP index 6d787c1..43e9975 100644 --- a/REDALERT/MENUS.CPP +++ b/REDALERT/MENUS.CPP @@ -40,6 +40,8 @@ #include #endif +#include + /***************************** ** Function prototypes ******************************/ @@ -806,7 +808,8 @@ int Main_Menu(unsigned long ) /* ** Get and process player input. - */ + */ + input = (KeyNumType)0; input = commands->Input(); #ifndef FIXIT_VERSION_3 diff --git a/REDALERT/MSGBOX.CPP b/REDALERT/MSGBOX.CPP index a84f03c..7f55a9e 100644 --- a/REDALERT/MSGBOX.CPP +++ b/REDALERT/MSGBOX.CPP @@ -82,7 +82,7 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t int curbutton; TextButtonClass * buttons[3]; void * back; - BOOL display; // display level + BOOL display = TRUE; // display level int realval[5]; #ifndef WIN32 diff --git a/REDALERT/RedAlert.vcxproj b/REDALERT/RedAlert.vcxproj index 04d0a8f..b593ec3 100644 --- a/REDALERT/RedAlert.vcxproj +++ b/REDALERT/RedAlert.vcxproj @@ -92,7 +92,7 @@ true true false - ./win32lib + ../external/sdl2/include;./win32lib true false WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;NDEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions) @@ -120,7 +120,7 @@ Level3 Disabled false - ./win32lib + ../external/sdl2/include;./win32lib false true ProgramDatabase @@ -782,6 +782,9 @@ + + + diff --git a/REDALERT/RedAlert.vcxproj.filters b/REDALERT/RedAlert.vcxproj.filters index 39e5841..229de23 100644 --- a/REDALERT/RedAlert.vcxproj.filters +++ b/REDALERT/RedAlert.vcxproj.filters @@ -19,6 +19,9 @@ {f4599de7-e877-410c-943f-afc4bef70eb6} + + {3254aa87-c780-4496-a35f-35ab3a6d4cc1} + @@ -1839,4 +1842,9 @@ Source Files\Resource + + + Source Files\sdl + + \ No newline at end of file diff --git a/REDALERT/WIN32LIB/MOUSEWW.CPP b/REDALERT/WIN32LIB/MOUSEWW.CPP index bdb952b..ed90190 100644 --- a/REDALERT/WIN32LIB/MOUSEWW.CPP +++ b/REDALERT/WIN32LIB/MOUSEWW.CPP @@ -702,18 +702,18 @@ extern int DLLForceMouseY; int Get_Mouse_X(void) { - if (DLLForceMouseX >= 0) { - return DLLForceMouseX; - } + //if (DLLForceMouseX >= 0) { + // return DLLForceMouseX; + //} if (!_Mouse) return(0); return(_Mouse->Get_Mouse_X()); } int Get_Mouse_Y(void) { - if (DLLForceMouseY >= 0) { - return DLLForceMouseY; - } + //if (DLLForceMouseY >= 0) { + // return DLLForceMouseY; + //} if (!_Mouse) return(0); return(_Mouse->Get_Mouse_Y()); diff --git a/REDALERT/WINSTUB.CPP b/REDALERT/WINSTUB.CPP index b7e4b9a..99aa7d8 100644 --- a/REDALERT/WINSTUB.CPP +++ b/REDALERT/WINSTUB.CPP @@ -51,9 +51,13 @@ #include "ipx95.h" #endif //WINSOCK_IPX +#include +#include + void output(short,short) {} +SDL_Window* game_window; unsigned long CCFocusMessage = WM_USER+50; //Private message for receiving application focus extern void VQA_PauseAudio(void); @@ -455,24 +459,31 @@ void Create_Main_Window ( HANDLE instance , int command_show , int width , int h // // Create our main window // - hwnd = CreateWindowEx ( - WS_EX_TOPMOST, - WINDOW_NAME, - WINDOW_NAME, - WS_POPUP, // Denzil | WS_MAXIMIZE, - 0, - 0, - // Denzil 5/18/98 - Making window fullscreen prevents other apps - // from getting WM_PAINT messages -// jmarshall - width, //width, - height, //height, -// jmarshall end - // End Denzil - NULL, - NULL, - (HINSTANCE)instance, - NULL ); +// hwnd = CreateWindowEx ( +// WS_EX_TOPMOST, +// WINDOW_NAME, +// WINDOW_NAME, +// WS_POPUP, // Denzil | WS_MAXIMIZE, +// 0, +// 0, +// // Denzil 5/18/98 - Making window fullscreen prevents other apps +// // from getting WM_PAINT messages +//// jmarshall +// width, //width, +// height, //height, +//// jmarshall end +// // End Denzil +// NULL, +// NULL, +// (HINSTANCE)instance, +// NULL ); + SDL_Init(SDL_INIT_VIDEO); + game_window = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN); + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWindowWMInfo(game_window, &wmInfo); + hwnd = wmInfo.info.win.window; + GameInFocus = TRUE; ShowWindow (hwnd, command_show ); ShowCommand = command_show;