From 40de33ca3cfad1d40952d8bc547c6a8227ea9307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Fri, 23 Mar 2012 22:53:56 +0100 Subject: [PATCH] win32: Make sdl-mainloop option work As it doesn't have the editor, this is only useful for compiling more of our code on more platforms. --- CMakeLists.txt | 87 +++++++++--------- Makefile.am | 58 +++++++----- configure.ac | 22 +++-- src/C4Application.cpp | 2 +- src/C4FullScreen.cpp | 137 --------------------------- src/C4FullScreen.h | 2 - src/c4group/C4ComponentHost.cpp | 1 - src/editor/C4Console.cpp | 6 +- src/editor/C4ConsoleGUI.h | 2 +- src/editor/C4EditCursor.cpp | 16 ++-- src/editor/C4EditCursor.h | 8 +- src/gui/C4Gui.cpp | 2 +- src/gui/C4Gui.h | 2 +- src/gui/C4GuiDialogs.cpp | 2 +- src/gui/C4KeyboardInput.cpp | 4 +- src/gui/C4MouseControl.cpp | 4 +- src/gui/C4Viewport.cpp | 2 +- src/gui/C4Viewport.h | 2 +- src/platform/C4App.h | 91 +++++++++--------- src/platform/C4AppSDL.cpp | 143 +++++++++++++++++++++++++---- src/platform/C4GamePadCon.cpp | 2 +- src/platform/C4GamePadCon.h | 6 +- src/platform/C4VideoPlayback.cpp | 10 +- src/platform/C4ViewportWindow.cpp | 2 +- src/platform/C4Window.h | 6 +- src/platform/PlatformAbstraction.h | 4 + src/platform/StdGL.cpp | 6 +- src/platform/StdGL.h | 6 +- src/platform/StdGLCtx.cpp | 2 +- src/platform/StdScheduler.cpp | 1 - src/script/C4Aul.cpp | 1 - 31 files changed, 313 insertions(+), 326 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5edb3a187..d59da4b06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,13 +556,21 @@ set(OC_CLONK_SOURCES mark_as_advanced(OC_CLONK_SOURCES) mark_as_advanced(OC_SYSTEM_SOURCES) +# source files specific to an operating system +if(APPLE) + list(APPEND OC_SYSTEM_SOURCES + src/platform/C4FileMonitorMac.mm + src/platform/ClonkAppDelegate.h + src/platform/ClonkAppDelegate.mm + ) +else() + list(APPEND OC_SYSTEM_SOURCES + src/C4WinMain.cpp + ) +endif() if(WIN32) list(APPEND OC_SYSTEM_SOURCES - src/platform/C4WindowWin32.cpp - src/platform/StdJoystick.cpp - src/platform/StdJoystick.h src/platform/C4CrashHandlerWin32.cpp - src/editor/C4ConsoleWin32.cpp src/res/resource.h ) @@ -588,45 +596,9 @@ if(WIN32) src/res/engine.rc ) endif(MINGW) -elseif(USE_SDL_MAINLOOP) - list(APPEND OC_SYSTEM_SOURCES - src/platform/C4AppSDL.cpp - src/platform/C4WindowSDL.cpp - ) -elseif(USE_X11) - list(APPEND OC_SYSTEM_SOURCES - src/platform/C4AppX.cpp - src/platform/C4WindowX.cpp - src/platform/C4AppXImpl.h - ) endif() -if(NOT APPLE) - list(APPEND OC_SYSTEM_SOURCES src/C4WinMain.cpp) -endif() - -if(APPLE) - list(APPEND OC_SYSTEM_SOURCES - src/platform/C4AppMac.mm - src/platform/C4FileMonitorMac.mm - src/platform/C4WindowMac.mm - src/platform/ClonkAppDelegate.h - src/platform/ClonkAppDelegate.mm - ) - if(USE_COCOA) - list(APPEND OC_SYSTEM_SOURCES - src/platform/ConsoleWindowController.h - src/platform/ConsoleWindowController.mm - src/platform/ClonkWindowController.h - src/platform/ClonkWindowController.mm - src/platform/ClonkOpenGLView.h - src/platform/ClonkOpenGLView.mm - src/platform/CocoaKeycodeMap.h - src/editor/C4ConsoleCocoa.mm - src/platform/ClonkMainMenuActions.mm - ) - endif() -endif() +# source files specific to a GUI library if(USE_GTK) list(APPEND OC_CLONK_SOURCES src/res/Brush.h @@ -645,11 +617,38 @@ if(USE_GTK) src/res/resource.h src/res/Static.h ) - list(APPEND OC_SYSTEM_SOURCES - src/platform/C4WindowGTK.cpp - src/platform/C4WindowGTK.h src/editor/C4ConsoleGTK.cpp + src/platform/C4AppX.cpp + src/platform/C4AppXImpl.h + src/platform/C4WindowGTK.cpp + src/platform/C4WindowX.cpp + ) +elseif(USE_SDL_MAINLOOP) + list(APPEND OC_SYSTEM_SOURCES + src/platform/C4AppSDL.cpp + src/platform/C4WindowSDL.cpp + ) +elseif(WIN32) + list(APPEND OC_SYSTEM_SOURCES + src/editor/C4ConsoleWin32.cpp + src/platform/C4WindowWin32.cpp + src/platform/StdJoystick.cpp + src/platform/StdJoystick.h + ) +elseif(USE_COCOA) + list(APPEND OC_SYSTEM_SOURCES + src/editor/C4ConsoleCocoa.mm + src/platform/C4AppMac.mm + src/platform/C4WindowMac.mm + src/platform/ClonkMainMenuActions.mm + src/platform/ClonkOpenGLView.h + src/platform/ClonkOpenGLView.mm + src/platform/ClonkWindowController.h + src/platform/ClonkWindowController.mm + src/platform/CocoaKeycodeMap.h + src/platform/ConsoleWindowController.h + src/platform/ConsoleWindowController.mm ) endif() if(WITH_AUTOMATIC_UPDATE) diff --git a/Makefile.am b/Makefile.am index c726c37b2..4209c0cbe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -217,8 +217,8 @@ src/game/C4GameVersion.h \ src/game/C4Physics.h \ src/game/landscape/C4Landscape.cpp \ src/game/landscape/C4Landscape.h \ -src/game/landscape/C4LandscapeRender.cpp \ src/game/landscape/C4LandscapeRenderClassic.cpp \ +src/game/landscape/C4LandscapeRender.cpp \ src/game/landscape/C4LandscapeRender.h \ src/game/landscape/C4Map.cpp \ src/game/landscape/C4MapCreatorS2.cpp \ @@ -254,9 +254,9 @@ src/game/object/C4Command.h \ src/game/object/C4Def.cpp \ src/game/object/C4DefGraphics.cpp \ src/game/object/C4DefGraphics.h \ +src/game/object/C4Def.h \ src/game/object/C4DefList.cpp \ src/game/object/C4DefList.h \ -src/game/object/C4Def.h \ src/game/object/C4GameObjects.cpp \ src/game/object/C4GameObjects.h \ src/game/object/C4Id.cpp \ @@ -280,9 +280,9 @@ src/game/object/C4ObjectList.cpp \ src/game/object/C4ObjectList.h \ src/game/object/C4ObjectMenu.cpp \ src/game/object/C4ObjectMenu.h \ -src/game/object/C4ObjectScript.cpp \ src/game/object/C4ObjectPtr.cpp \ src/game/object/C4ObjectPtr.h \ +src/game/object/C4ObjectScript.cpp \ src/game/object/C4Sector.cpp \ src/game/object/C4Sector.h \ src/game/object/C4Shape.cpp \ @@ -453,6 +453,9 @@ src/network/C4Packet2.cpp \ src/network/C4PacketBase.h \ src/platform/Bitmap256.cpp \ src/platform/Bitmap256.h \ +src/platform/C4App.cpp \ +src/platform/C4App.h \ +src/platform/C4AppT.cpp \ src/platform/C4FileMonitor.cpp \ src/platform/C4FileMonitor.h \ src/platform/C4Fonts.cpp \ @@ -467,17 +470,18 @@ src/platform/C4SoundLoaders.cpp \ src/platform/C4SoundLoaders.h \ src/platform/C4SoundSystem.cpp \ src/platform/C4SoundSystem.h \ +src/platform/C4Surface.cpp \ +src/platform/C4Surface.h \ src/platform/C4Video.cpp \ src/platform/C4Video.h \ src/platform/C4VideoPlayback.cpp \ src/platform/C4VideoPlayback.h \ src/platform/C4ViewportWindow.cpp \ src/platform/C4ViewportWindow.h \ +src/platform/C4Window.h \ src/platform/C4windowswrapper.h \ src/platform/PlatformAbstraction.cpp \ src/platform/PlatformAbstraction.h \ -src/platform/C4App.h \ -src/platform/C4App.cpp \ src/platform/StdD3D.cpp \ src/platform/StdD3D.h \ src/platform/StdD3DShader.cpp \ @@ -491,15 +495,11 @@ src/platform/StdGLCtx.cpp \ src/platform/StdGL.h \ src/platform/StdNoGfx.cpp \ src/platform/StdNoGfx.h \ -src/platform/C4Surface.cpp \ -src/platform/C4Surface.h \ src/platform/StdSurface8.cpp \ src/platform/StdSurface8.h \ src/platform/StdSync.h \ -src/platform/C4AppT.cpp \ src/platform/StdVideo.cpp \ src/platform/StdVideo.h \ -src/platform/C4Window.h \ src/res/Brush.h \ src/res/Cursor.h \ src/res/Dynamic.h \ @@ -542,21 +542,40 @@ thirdparty/timsort/sort.h \ thirdparty/tinyxml/tinystr.cpp \ thirdparty/tinyxml/tinystr.h \ thirdparty/tinyxml/tinyxml.cpp \ -thirdparty/tinyxml/tinyxml.h \ thirdparty/tinyxml/tinyxmlerror.cpp \ +thirdparty/tinyxml/tinyxml.h \ thirdparty/tinyxml/tinyxmlparser.cpp if WIN32 clonk_SOURCES += \ -src/editor/C4ConsoleWin32.cpp \ src/platform/C4CrashHandlerWin32.cpp \ src/res/engine.rc \ -src/res/resource.h \ +src/res/resource.h +endif + +if SDL_MAIN_LOOP +clonk_SOURCES += \ +src/platform/C4AppSDL.cpp \ +src/platform/C4WindowSDL.cpp +else +if GTK +clonk_SOURCES += \ +src/editor/C4ConsoleGTK.cpp \ +src/platform/C4AppX.cpp \ +src/platform/C4AppXImpl.h \ +src/platform/C4WindowGTK.cpp \ +src/platform/C4WindowX.cpp +else +if WIN32 +clonk_SOURCES += \ +src/editor/C4ConsoleWin32.cpp \ +src/platform/C4WindowWin32.cpp \ src/platform/StdJoystick.cpp \ src/platform/StdJoystick.h endif if MACOSX clonk_SOURCES += \ +src/editor/C4ConsoleCocoa.mm \ src/platform/C4AppMac.mm \ src/platform/C4FileMonitorMac.mm \ src/platform/C4WindowMac.mm \ @@ -569,22 +588,12 @@ src/platform/ClonkWindowController.mm \ src/platform/ClonkOpenGLView.h \ src/platform/ClonkOpenGLView.mm \ src/platform/CocoaKeycodeMap.h \ -src/editor/C4ConsoleCocoa.mm \ src/platform/ClonkMainMenuActions.h \ src/platform/ClonkMainMenuActions.mm endif -if SDL_MAIN_LOOP -clonk_SOURCES += src/platform/C4AppSDL.cpp src/platform/C4WindowSDL.cpp -else -if WIN32 -clonk_SOURCES += src/platform/C4WindowWin32.cpp -else -clonk_SOURCES += src/platform/C4AppX.cpp src/platform/C4WindowX.cpp src/platform/C4AppXImpl.h endif endif -if DEVELOPER_MODE -clonk_SOURCES += src/platform/C4WindowGTK.cpp src/platform/C4WindowGTK.h src/editor/C4ConsoleGTK.cpp -endif + if LIBUPNP clonk_SOURCES += src/network/C4Network2UPnPLinux.cpp else @@ -630,7 +639,8 @@ c4group_CPPFLAGS = \ -I$(srcdir)/src/game \ -I$(srcdir)/src/game/object \ -I$(srcdir)/src/lib/texture \ - -I$(srcdir)/src/script + -I$(srcdir)/src/script \ +$(BOOST_CPPFLAGS) c4group_SOURCES = \ src/lib/C4SimpleLog.cpp \ diff --git a/configure.ac b/configure.ac index 63bfb56ee..615638f9b 100644 --- a/configure.ac +++ b/configure.ac @@ -139,7 +139,7 @@ AS_IF([test $with_gtk != no],[ AC_DEFINE([WITH_GLIB], 1, [Glib]) AC_DEFINE([WITH_DEVELOPER_MODE], 1, [Developer mode]) ]) -AM_CONDITIONAL(DEVELOPER_MODE, [test $with_gtk != no]) +AM_CONDITIONAL(GTK, [test $with_gtk != no]) # OpenAL AC_ARG_WITH([openal], @@ -241,15 +241,17 @@ AC_CHECK_LIB(rt, clock_gettime, [ # Check for libfreetype if test $enable_console = no; then - if test "$cross_compiling" = no; then - AC_CHECK_PROG(FREETYPE_CONFIG, freetype-config, freetype-config) - fi - if test $FREETYPE_CONFIG; then - AC_SUBST(FREETYPE_CFLAGS, [`$FREETYPE_CONFIG --cflags`]) - AC_SUBST(FREETYPE_LIBS, [`$FREETYPE_CONFIG --libs`]) - else - PKG_CHECK_MODULES(FREETYPE, freetype2) - fi + PKG_CHECK_MODULES(FREETYPE, freetype2, ,[ + if test "$cross_compiling" = no; then + AC_CHECK_PROG(FREETYPE_CONFIG, freetype-config, freetype-config) + fi + if test $FREETYPE_CONFIG; then + AC_SUBST(FREETYPE_CFLAGS, [`$FREETYPE_CONFIG --cflags`]) + AC_SUBST(FREETYPE_LIBS, [`$FREETYPE_CONFIG --libs`]) + else + AC_MSG_ERROR([Freetype not found.]) + fi + ]) AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if you have FreeType2.]) fi diff --git a/src/C4Application.cpp b/src/C4Application.cpp index 153d2f08e..6ff9e1f7b 100644 --- a/src/C4Application.cpp +++ b/src/C4Application.cpp @@ -736,7 +736,7 @@ void C4Application::OnCommand(const char *szCmd) void C4Application::Activate() { -#ifdef WIN32 +#ifdef USE_WIN32_WINDOWS // Activate the application to regain focus if it has been lost during loading. // As this is officially not possible any more in new versions of Windows // (BringWindowTopTop alone won't have any effect if the calling process is diff --git a/src/C4FullScreen.cpp b/src/C4FullScreen.cpp index 580726425..5a388e889 100644 --- a/src/C4FullScreen.cpp +++ b/src/C4FullScreen.cpp @@ -147,143 +147,6 @@ void C4FullScreen::HandleMessage (XEvent &e) } } -#elif defined(USE_SDL_MAINLOOP) -// SDL version - -namespace -{ - void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, - int32_t& button, DWORD& flags) - { - static int lastLeftClick = 0, lastRightClick = 0; - static int lastX = 0, lastY = 0; - static const int clickDist = 2; - - button = C4MC_Button_None; - flags = 0; - - switch (e.button) - { - case SDL_BUTTON_LEFT: - if (e.state == SDL_PRESSED) - if (GetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist) - { - lastLeftClick = 0; - button = C4MC_Button_LeftDouble; - } - else - { - lastLeftClick = GetTime(); - button = C4MC_Button_LeftDown; - } - else - button = C4MC_Button_LeftUp; - break; - case SDL_BUTTON_RIGHT: - if (e.state == SDL_PRESSED) - if (GetTime() - lastRightClick < 400) - { - lastRightClick = 0; - button = C4MC_Button_RightDouble; - } - else - { - lastRightClick = GetTime(); - button = C4MC_Button_RightDown; - } - else - button = C4MC_Button_RightUp; - break; - case SDL_BUTTON_MIDDLE: - if (e.state == SDL_PRESSED) - button = C4MC_Button_MiddleDown; - else - button = C4MC_Button_MiddleUp; - break; - case SDL_BUTTON_WHEELUP: - button = C4MC_Button_Wheel; - flags = (+32) << 16; - break; - case SDL_BUTTON_WHEELDOWN: - button = C4MC_Button_Wheel; - flags = (-32) << 16; - break; - } - lastX = e.x; - lastY = e.y; - } - - bool isSpecialKey(unsigned unicode) - { - if (unicode >= 0xe00) - return true; - if (unicode < 32 || unicode == 127) - return true; - return false; - } -} - -#include "StdGL.h" - -void C4FullScreen::HandleMessage (SDL_Event &e) -{ - switch (e.type) - { - case SDL_KEYDOWN: - { -#ifdef USE_GL - if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA))) - { - Config.Graphics.Windowed = !Config.Graphics.Windowed; - Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed); - pDraw->InvalidateDeviceObjects(); - pDraw->RestoreDeviceObjects(); - - break; - } -#endif - - // Only forward real characters to UI. (Nothing outside of "private use" range.) - // This works without iconv for some reason. Yay! - // FIXME: convert to UTF-8 - char c[2]; - c[0] = e.key.keysym.unicode; - c[1] = 0; - if (!isSpecialKey(e.key.keysym.unicode)) - ::pGUI->CharIn(c); - Game.DoKeyboardInput(e.key.keysym.sym, KEYEV_Down, - e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), - e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), - e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), - false, NULL); - break; - } - case SDL_KEYUP: - Game.DoKeyboardInput(e.key.keysym.sym, KEYEV_Up, - e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), - e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), - e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), false, NULL); - break; - case SDL_MOUSEMOTION: - C4GUI::MouseMove(C4MC_Button_None, e.motion.x, e.motion.y, 0, NULL); - break; - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEBUTTONDOWN: - int32_t button; - DWORD flags; - sdlToC4MCBtn(e.button, button, flags); - C4GUI::MouseMove(button, e.button.x, e.button.y, flags, NULL); - break; - case SDL_JOYAXISMOTION: - case SDL_JOYHATMOTION: - case SDL_JOYBALLMOTION: - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - Application.pGamePadControl->FeedEvent(e); - break; - } -} - #endif // _WIN32, USE_X11, USE_SDL_MAINLOOP void C4FullScreen::CharIn(const char * c) { ::pGUI->CharIn(c); } diff --git a/src/C4FullScreen.h b/src/C4FullScreen.h index 4b757c5bc..edc4e34fc 100644 --- a/src/C4FullScreen.h +++ b/src/C4FullScreen.h @@ -51,8 +51,6 @@ public: virtual void CharIn(const char * c); #ifdef USE_X11 virtual void HandleMessage (XEvent &e); -#elif defined(USE_SDL_MAINLOOP) - virtual void HandleMessage (SDL_Event &e); #elif defined(USE_COCOA) virtual void HandleMessage (/*NSEvent*/void* event); #endif diff --git a/src/c4group/C4ComponentHost.cpp b/src/c4group/C4ComponentHost.cpp index 0764a777c..fe1b840bb 100644 --- a/src/c4group/C4ComponentHost.cpp +++ b/src/c4group/C4ComponentHost.cpp @@ -26,7 +26,6 @@ #include #include -#include #include bool C4ComponentHost::Load(C4Group &hGroup, diff --git a/src/editor/C4Console.cpp b/src/editor/C4Console.cpp index 64a4bbd7f..9881bccec 100644 --- a/src/editor/C4Console.cpp +++ b/src/editor/C4Console.cpp @@ -59,7 +59,7 @@ C4Console::C4Console(): C4ConsoleGUI() FrameCounter=0; fGameOpen=false; -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS hWindow=NULL; #endif } @@ -555,7 +555,7 @@ bool C4Console::TogglePause() return Game.TogglePause(); } -#if !(defined(_WIN32) || defined(USE_COCOA) || defined(WITH_DEVELOPER_MODE)) +#if !(defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(WITH_DEVELOPER_MODE)) class C4ConsoleGUI::State: public C4ConsoleGUI::InternalState { public: State(C4ConsoleGUI *console): Super(console) {} @@ -580,7 +580,7 @@ C4Window * C4ConsoleGUI::CreateConsoleWindow(C4AbstractApp*) {return 0;} void C4ConsoleGUI::DisplayInfoText(C4ConsoleGUI::InfoTextType, StdStrBuf&) {} void C4ConsoleGUI::DoEnableControls(bool) {} bool C4ConsoleGUI::DoUpdateHaltCtrls(bool) {return 0;} -bool C4ConsoleGUI::FileSelect(StdStrBuf *, char const*, unsigned int, bool) {return 0;} +bool C4ConsoleGUI::FileSelect(StdStrBuf *, char const*, DWORD, bool) {return 0;} bool C4ConsoleGUI::Message(char const*, bool) {return 0;} void C4ConsoleGUI::Out(char const*) {} bool C4ConsoleGUI::PropertyDlgOpen() {return 0;} diff --git a/src/editor/C4ConsoleGUI.h b/src/editor/C4ConsoleGUI.h index ce2c58b00..ee3842634 100644 --- a/src/editor/C4ConsoleGUI.h +++ b/src/editor/C4ConsoleGUI.h @@ -141,7 +141,7 @@ public: void ToolsDlgSelectTexture(C4ToolsDlg *dlg, const char *texture); void ToolsDlgSelectMaterial(C4ToolsDlg *dlg, const char *material); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS void Win32KeepDialogsFloating(HWND hwnd = 0); virtual bool Win32DialogMessageHandling(MSG *msg); void UpdateMenuText(HMENU hMenu); diff --git a/src/editor/C4EditCursor.cpp b/src/editor/C4EditCursor.cpp index 3406ca803..1defdaba4 100644 --- a/src/editor/C4EditCursor.cpp +++ b/src/editor/C4EditCursor.cpp @@ -97,7 +97,7 @@ void C4EditCursor::Execute() bool C4EditCursor::Init() { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS if (!(hMenu = LoadMenu(Application.GetInstance(),MAKEINTRESOURCE(IDR_CONTEXTMENUS)))) return false; #else // _WIN32 @@ -336,7 +336,7 @@ bool C4EditCursor::LeftButtonUp() return true; } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS bool SetMenuItemEnable(HMENU hMenu, WORD id, bool fEnable) { return !!EnableMenuItem(hMenu,id,MF_BYCOMMAND | MF_ENABLED | ( fEnable ? 0 : MF_GRAYED)); @@ -513,7 +513,7 @@ void C4EditCursor::Default() Mode=C4CNS_ModePlay; X=Y=X2=Y2=0; Target=DropTarget=NULL; -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS hMenu=NULL; #endif Hold=DragFrame=DragLine=false; @@ -522,7 +522,7 @@ void C4EditCursor::Default() void C4EditCursor::Clear() { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS if (hMenu) DestroyMenu(hMenu); hMenu=NULL; #endif #ifdef WITH_DEBUG_MODE @@ -534,7 +534,7 @@ void C4EditCursor::Clear() bool C4EditCursor::SetMode(int32_t iMode) { // Store focus -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS HWND hFocus=GetFocus(); #endif // Update console buttons (always) @@ -563,7 +563,7 @@ bool C4EditCursor::SetMode(int32_t iMode) ::MouseControl.HideCursor(); } // Restore focus -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS SetFocus(hFocus); #endif // Done @@ -627,7 +627,7 @@ void C4EditCursor::ApplyToolFill() bool C4EditCursor::DoContextMenu() { bool fObjectSelected = !!Selection.ObjectCount(); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS POINT point; GetCursorPos(&point); HMENU hContext = GetSubMenu(hMenu,0); SetMenuItemEnable( hContext, IDM_VIEWPORT_DELETE, fObjectSelected && Console.Editing); @@ -882,7 +882,7 @@ void C4EditCursor::ObjselectDelItems() { while(it != itemsObjselect.end()) { #if defined(WITH_DEVELOPER_MODE) gtk_widget_destroy(it->MenuItem); - #elif defined(_WIN32) + #elif defined(USE_WIN32_WINDOWS) if(!it->ItemId) { ++it; continue; } HMENU hContext = GetSubMenu(hMenu,0); DeleteMenu(hContext, it->ItemId, MF_BYCOMMAND); diff --git a/src/editor/C4EditCursor.h b/src/editor/C4EditCursor.h index 0f15e6017..2e8913e0c 100644 --- a/src/editor/C4EditCursor.h +++ b/src/editor/C4EditCursor.h @@ -47,24 +47,22 @@ protected: struct ObjselItemDt { C4EditCursor* EditCursor; C4Object* Object; -#if defined(_WIN32) +#if defined(USE_WIN32_WINDOWS) UINT_PTR ItemId; #elif defined(WITH_DEVELOPER_MODE) GtkWidget* MenuItem; #endif }; std::vector itemsObjselect; -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS HMENU hMenu; -#else -#ifdef WITH_DEVELOPER_MODE +#elif defined(WITH_DEVELOPER_MODE) GtkWidget* menuContext; GtkWidget* itemDelete; GtkWidget* itemDuplicate; GtkWidget* itemGrabContents; GtkWidget* itemProperties; #endif -#endif // _WIN32 C4ObjectList Selection; public: void Default(); diff --git a/src/gui/C4Gui.cpp b/src/gui/C4Gui.cpp index 9c39785f5..d3dcee4be 100644 --- a/src/gui/C4Gui.cpp +++ b/src/gui/C4Gui.cpp @@ -675,7 +675,7 @@ namespace C4GUI { while (pActiveDlg) pActiveDlg->Close(fWithOK); } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS Dialog *Screen::GetDialog(HWND hWindow) { // get dialog with matching handle diff --git a/src/gui/C4Gui.h b/src/gui/C4Gui.h index 0a6c3c992..2159daad4 100644 --- a/src/gui/C4Gui.h +++ b/src/gui/C4Gui.h @@ -2563,7 +2563,7 @@ namespace C4GUI void CloseAllDialogs(bool fWithOK); // close all dialogs on the screen; top dlgs first void SetPreferredDlgRect(const C4Rect &rtNewPref) { PreferredDlgRect = rtNewPref; } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS Dialog *GetDialog(HWND hWindow); // get console dialog #endif Dialog *GetDialog(C4Window * pWindow); // get console dialog diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index 69b9e7532..4fa38ac6b 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -193,7 +193,7 @@ namespace C4GUI // -------------------------------------------------- // DialogWindow -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS C4Window * DialogWindow::Init(C4Window::WindowKind windowKind, C4AbstractApp * pApp, const char * Title, C4Window * pParent, const C4Rect &rcBounds, const char *szID) { Active = true; diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 0d58bbaae..66d3d5e9c 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -40,11 +40,11 @@ #include #ifdef USE_SDL_MAINLOOP -#include +#include #include #include -#include +#include namespace { diff --git a/src/gui/C4MouseControl.cpp b/src/gui/C4MouseControl.cpp index 9eaef1e51..41ef01f43 100644 --- a/src/gui/C4MouseControl.cpp +++ b/src/gui/C4MouseControl.cpp @@ -202,7 +202,7 @@ void C4MouseControl::UpdateClip() // never in debug return; #endif -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS // fullscreen only if (Application.isEditor) return; // application or mouse control not active? remove any clips @@ -250,7 +250,7 @@ void C4MouseControl::Move(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyFl fctViewportGame = Viewport->last_game_draw_cgo; fctViewportGUI = Viewport->last_gui_draw_cgo; // First time viewport attachment: center mouse -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS if (!InitCentered || fCenter) { iX = Viewport->ViewWdt/2; diff --git a/src/gui/C4Viewport.cpp b/src/gui/C4Viewport.cpp index 16a698f91..1496cd0b0 100644 --- a/src/gui/C4Viewport.cpp +++ b/src/gui/C4Viewport.cpp @@ -817,7 +817,7 @@ bool C4ViewportList::CloseViewport(C4Viewport * cvp) // Done return true; } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS C4Viewport* C4ViewportList::GetViewport(HWND hwnd) { for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next) diff --git a/src/gui/C4Viewport.h b/src/gui/C4Viewport.h index d2247f5b8..6b76e48d8 100644 --- a/src/gui/C4Viewport.h +++ b/src/gui/C4Viewport.h @@ -121,7 +121,7 @@ public: C4Viewport* GetViewport(int32_t iPlayer, C4Viewport* pPrev = NULL); C4Viewport* GetFirstViewport() { return FirstViewport; } bool CloseViewport(C4Viewport * cvp); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS C4Viewport* GetViewport(HWND hwnd); #endif int32_t GetAudibility(int32_t iX, int32_t iY, int32_t *iPan, int32_t iAudibilityRadius=0); diff --git a/src/platform/C4App.h b/src/platform/C4App.h index 344082fac..3777abc46 100644 --- a/src/platform/C4App.h +++ b/src/platform/C4App.h @@ -28,10 +28,7 @@ #include #endif -#ifdef _WIN32 -#include - -#elif defined(USE_X11) +#if defined(USE_X11) // do not include xlib.h typedef struct _XDisplay Display; // from X.h: @@ -54,9 +51,11 @@ typedef struct _XDisplay Display; extern int MK_SHIFT; extern int MK_CONTROL; extern int MK_ALT; +#elif defined(USE_WIN32_WINDOWS) +#include #endif -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS class CStdMessageProc : public StdSchedulerProc { public: @@ -137,17 +136,13 @@ public: void MessageDialog(const char * message); const char *GetLastError() { return sLastError.getData(); } void Error(const char * m) { sLastError.Copy(m); } -#ifdef _WIN32 +#ifdef _WIN32 private: HINSTANCE hInstance; HANDLE hMainThread; // handle to main thread that initialized the app - CStdMessageProc MessageProc; public: - bool IsShiftDown() { return GetKeyState(VK_SHIFT) < 0; } - bool IsControlDown() { return GetKeyState(VK_CONTROL) < 0; } - bool IsAltDown() { return GetKeyState(VK_MENU) < 0; } void SetInstance(HINSTANCE hInst) { hInstance = hInst; } HINSTANCE GetInstance() const { return hInstance; } bool AssertMainThread() @@ -161,6 +156,49 @@ public: # endif return true; } +#else + bool AssertMainThread() + { + assert(MainThread == pthread_self()); + return MainThread == pthread_self(); + } + pthread_t MainThread; +#endif + +#if defined(USE_X11) +public: + Display * dpy; + int xf86vmode_major_version, xf86vmode_minor_version; + int xrandr_major_version, xrandr_minor_version; + // These must be public to be callable from callback functions from + // the glib main loop that are in an anonymous namespace in + // StdXApp.cpp. + void OnXInput(); +protected: + class C4X11AppImpl * Priv; + void HandleXMessage(); + +#elif defined(USE_SDL_MAINLOOP) +public: + void HandleSDLEvent(SDL_Event& event); + +#elif defined(USE_COCOA) +public: + void HandleNSEvent(/*NSEvent*/void* event); + StdStrBuf GetGameDataPath(); + +#elif defined(USE_CONSOLE) +protected: + CStdInProc InProc; +#endif + +#ifdef USE_WIN32_WINDOWS +private: + CStdMessageProc MessageProc; +public: + bool IsShiftDown() { return GetKeyState(VK_SHIFT) < 0; } + bool IsControlDown() { return GetKeyState(VK_CONTROL) < 0; } + bool IsAltDown() { return GetKeyState(VK_MENU) < 0; } PIXELFORMATDESCRIPTOR &GetPFD() { return pfd; } HMONITOR hMon; // monitor handle of used monitor RECT MonitorRect; // output window rect @@ -168,43 +206,14 @@ protected: PIXELFORMATDESCRIPTOR pfd; // desired pixel format DEVMODEW dspMode, OldDspMode;// display mode for fullscreen #else -# if defined(USE_X11) - Display * dpy; - int xf86vmode_major_version, xf86vmode_minor_version; - int xrandr_major_version, xrandr_minor_version; -# endif - -# if defined(USE_SDL_MAINLOOP) - void HandleSDLEvent(SDL_Event& event); -# endif -#ifdef USE_COCOA - void HandleNSEvent(/*NSEvent*/void* event); - StdStrBuf GetGameDataPath(); -#endif - pthread_t MainThread; +public: bool IsShiftDown() { return KeyMask & MK_SHIFT; } bool IsControlDown() { return KeyMask & MK_CONTROL; } bool IsAltDown() { return KeyMask & MK_ALT; } - bool AssertMainThread() - { - assert(MainThread == pthread_self()); - return MainThread == pthread_self(); - } - // These must be public to be callable from callback functions from - // the glib main loop that are in an anonymous namespace in - // StdXApp.cpp. - void OnXInput(); -protected: -# ifdef USE_X11 - class C4X11AppImpl * Priv; - void HandleXMessage(); -# endif unsigned int KeyMask; #endif + protected: -#ifdef USE_CONSOLE - CStdInProc InProc; -#endif StdStrBuf sLastError; bool fDspModeSet; // true if display mode was changed virtual bool DoInit(int argc, char * argv[]) = 0;; diff --git a/src/platform/C4AppSDL.cpp b/src/platform/C4AppSDL.cpp index 251d480ee..1044aa52c 100644 --- a/src/platform/C4AppSDL.cpp +++ b/src/platform/C4AppSDL.cpp @@ -1,8 +1,8 @@ /* * OpenClonk, http://www.openclonk.org * - * Copyright (c) 2006 Julian Raschke - * Copyright (c) 2008-2009 Günther Brammer + * Copyright (c) 2006-2007 Julian Raschke + * Copyright (c) 2008-2009, 2011-2012 Günther Brammer * Copyright (c) 2009 Martin Plicht * Copyright (c) 2010 Benjamin Herr * Copyright (c) 2010 Peter Wortmann @@ -30,18 +30,84 @@ #include #include #include +#include +#include +#include +#include +// SDL version -#include -#include -#include -#include -#include -#include +static void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, int32_t& button, DWORD& flags) +{ + static int lastLeftClick = 0, lastRightClick = 0; + static int lastX = 0, lastY = 0; + static const int clickDist = 2; + + button = C4MC_Button_None; + flags = 0; + + switch (e.button) + { + case SDL_BUTTON_LEFT: + if (e.state == SDL_PRESSED) + if (GetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist) + { + lastLeftClick = 0; + button = C4MC_Button_LeftDouble; + } + else + { + lastLeftClick = GetTime(); + button = C4MC_Button_LeftDown; + } + else + button = C4MC_Button_LeftUp; + break; + case SDL_BUTTON_RIGHT: + if (e.state == SDL_PRESSED) + if (GetTime() - lastRightClick < 400) + { + lastRightClick = 0; + button = C4MC_Button_RightDouble; + } + else + { + lastRightClick = GetTime(); + button = C4MC_Button_RightDown; + } + else + button = C4MC_Button_RightUp; + break; + case SDL_BUTTON_MIDDLE: + if (e.state == SDL_PRESSED) + button = C4MC_Button_MiddleDown; + else + button = C4MC_Button_MiddleUp; + break; + case SDL_BUTTON_WHEELUP: + button = C4MC_Button_Wheel; + flags = (+32) << 16; + break; + case SDL_BUTTON_WHEELDOWN: + button = C4MC_Button_Wheel; + flags = (-32) << 16; + break; + } + lastX = e.x; + lastY = e.y; +} /* C4AbstractApp */ -C4AbstractApp::C4AbstractApp(): Active(false), fQuitMsgReceived(false), - MainThread(pthread_self()), fDspModeSet(false) +C4AbstractApp::C4AbstractApp(): + Active(false), pWindow(NULL), fQuitMsgReceived(false), + // main thread +#ifdef HAVE_PTHREAD + MainThread (pthread_self()), +#endif +#ifdef _WIN32 + hMainThread(NULL), +#endif + fDspModeSet(false) { } @@ -93,23 +159,66 @@ bool C4AbstractApp::FlushMessages() return true; } -void C4AbstractApp::HandleSDLEvent(SDL_Event& event) +void C4AbstractApp::HandleSDLEvent(SDL_Event& e) { // Directly handle QUIT messages. - switch (event.type) + switch (e.type) { case SDL_QUIT: Quit(); break; + case SDL_KEYDOWN: + { +#ifdef USE_GL + if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA))) + { + Config.Graphics.Windowed = !Config.Graphics.Windowed; + Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed); + pDraw->InvalidateDeviceObjects(); + pDraw->RestoreDeviceObjects(); + + break; + } +#endif + + StdStrBuf c; + c.AppendCharacter(e.key.keysym.unicode); + ::pGUI->CharIn(c.getData()); + Game.DoKeyboardInput(e.key.keysym.sym, KEYEV_Down, + e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), + e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), + e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), + false, NULL); + break; + } + case SDL_KEYUP: + Game.DoKeyboardInput(e.key.keysym.sym, KEYEV_Up, + e.key.keysym.mod & (KMOD_LALT | KMOD_RALT), + e.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL), + e.key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT), false, NULL); + break; + case SDL_MOUSEMOTION: + C4GUI::MouseMove(C4MC_Button_None, e.motion.x, e.motion.y, 0, NULL); + break; + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: + int32_t button; + DWORD flags; + sdlToC4MCBtn(e.button, button, flags); + C4GUI::MouseMove(button, e.button.x, e.button.y, flags, NULL); + break; + case SDL_JOYAXISMOTION: + case SDL_JOYHATMOTION: + case SDL_JOYBALLMOTION: + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + Application.pGamePadControl->FeedEvent(e); + break; } #ifdef __APPLE__ MacUtility::ensureWindowInFront(); #endif - - // Everything else goes to the window. - if (pWindow) - pWindow->HandleMessage(event); } bool C4AbstractApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor) @@ -186,7 +295,7 @@ bool C4AbstractApp::Copy(const StdStrBuf & text, bool fClipboard) StdStrBuf C4AbstractApp::Paste(bool fClipboard) { - return StdStrBuf(0); + return StdStrBuf(""); } bool C4AbstractApp::IsClipboardFull(bool fClipboard) diff --git a/src/platform/C4GamePadCon.cpp b/src/platform/C4GamePadCon.cpp index 4a26b6fd5..8ddb08f36 100644 --- a/src/platform/C4GamePadCon.cpp +++ b/src/platform/C4GamePadCon.cpp @@ -39,7 +39,7 @@ void C4GamePadControl::DoAxisInput() Execute(true); } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS //#include C4GamePadControl *C4GamePadControl::pInstance = NULL; diff --git a/src/platform/C4GamePadCon.h b/src/platform/C4GamePadCon.h index 92f2d4431..c818171df 100644 --- a/src/platform/C4GamePadCon.h +++ b/src/platform/C4GamePadCon.h @@ -24,7 +24,7 @@ #ifndef INC_C4GamePadCon #define INC_C4GamePadCon -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS #include #endif @@ -41,7 +41,7 @@ typedef union SDL_Event SDL_Event; class C4GamePadControl { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS private: struct Pad { @@ -78,7 +78,7 @@ public: class C4GamePadOpener { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS int iGamePad; int GetGamePadIndex() const { return iGamePad; } #endif diff --git a/src/platform/C4VideoPlayback.cpp b/src/platform/C4VideoPlayback.cpp index 629154458..9ee6feb75 100644 --- a/src/platform/C4VideoPlayback.cpp +++ b/src/platform/C4VideoPlayback.cpp @@ -39,7 +39,7 @@ class C4VideoShowDialog : public C4GUI::FullscreenDialog { private: -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS CStdAVIFile AVIFile; C4SoundEffect *pAudioTrack; #endif @@ -59,7 +59,7 @@ protected: public: C4VideoShowDialog() : C4GUI::FullscreenDialog(NULL, NULL) -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS , pAudioTrack(NULL) #endif #ifdef HAVE_LIBSDL_MIXER @@ -127,7 +127,7 @@ bool C4VideoFile::Load(class C4Group &hGrp, const char *szFilename) bool C4VideoShowDialog::LoadVideo(C4VideoFile *pVideoFile) { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS // load video file if (!AVIFile.OpenFile(pVideoFile->GetFilename(), FullScreen.hWindow, pDraw->GetByteCnt()*8)) return false; // prepare surface for display @@ -204,7 +204,7 @@ bool C4VideoShowDialog::LoadVideo(C4VideoFile *pVideoFile) C4VideoShowDialog::~C4VideoShowDialog() { -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS if (pAudioTrack) delete pAudioTrack; #else #ifdef HAVE_LIBSMPEG @@ -229,7 +229,7 @@ void C4VideoShowDialog::VideoDone() void C4VideoShowDialog::DrawElement(C4TargetFacet &cgo) { // draw current video frame -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS // get frame to be drawn time_t iCurrFrameTime = GetTime(); int32_t iGetFrame; diff --git a/src/platform/C4ViewportWindow.cpp b/src/platform/C4ViewportWindow.cpp index 3c4290f0e..3c6058cab 100644 --- a/src/platform/C4ViewportWindow.cpp +++ b/src/platform/C4ViewportWindow.cpp @@ -45,7 +45,7 @@ #endif #endif -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS void UpdateWindowLayout(HWND hwnd) { diff --git a/src/platform/C4Window.h b/src/platform/C4Window.h index 11ae6cfa1..bf5459893 100644 --- a/src/platform/C4Window.h +++ b/src/platform/C4Window.h @@ -29,7 +29,7 @@ #include -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS #include #define K_ALT VK_MENU #define K_ESCAPE VK_ESCAPE @@ -292,7 +292,7 @@ public: void SetTitle(const char * Title); void FlashWindow(); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS public: HWND hWindow; HWND hRenderWindow; @@ -313,8 +313,6 @@ protected: #elif defined(USE_SDL_MAINLOOP) private: int width, height; -protected: - virtual void HandleMessage(SDL_Event&) {} #elif defined(USE_COCOA) protected: /*ClonkWindowController*/void* controller; diff --git a/src/platform/PlatformAbstraction.h b/src/platform/PlatformAbstraction.h index a929d54c3..bbf5d729a 100644 --- a/src/platform/PlatformAbstraction.h +++ b/src/platform/PlatformAbstraction.h @@ -56,6 +56,10 @@ #endif #endif +#if defined(_WIN32) && !defined(USE_CONSOLE) && !defined(USE_SDL_MAINLOOP) && !defined(USE_X11) && !defined(USE_COCOA) +#define USE_WIN32_WINDOWS +#endif + #ifdef _MSC_VER #define DEPRECATED __declspec(deprecated) #elif defined(__GNUC__) diff --git a/src/platform/StdGL.cpp b/src/platform/StdGL.cpp index eddb70181..eff4df739 100644 --- a/src/platform/StdGL.cpp +++ b/src/platform/StdGL.cpp @@ -1676,7 +1676,7 @@ CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp) return pCtx; } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS CStdGLCtx *CStdGL::CreateContext(HWND hWindow, C4AbstractApp *pApp) { // safety @@ -2079,7 +2079,7 @@ void CStdGL::TaskOut() { // deactivate // backup textures -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS if (pTexMgr && !Editor) pTexMgr->IntLock(); if (pCurrCtx) pCurrCtx->Deselect(); @@ -2096,7 +2096,7 @@ void CStdGL::TaskIn() { // restore gl //if (!DeviceReady()) MainCtx.Init(pWindow, pApp); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS // restore textures if (pTexMgr && !Editor) pTexMgr->IntUnlock(); diff --git a/src/platform/StdGL.h b/src/platform/StdGL.h index ada63b0b5..2e30b5ab8 100644 --- a/src/platform/StdGL.h +++ b/src/platform/StdGL.h @@ -47,7 +47,7 @@ public: void Clear(); // clear objects -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS bool Init(C4Window * pWindow, C4AbstractApp *pApp, HWND hWindow = NULL); std::vector EnumerateMultiSamples() const; #else @@ -67,7 +67,7 @@ protected: void SelectCommon(); // this handles are declared as pointers to structs C4Window * pWindow; // window to draw in -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS HGLRC hrc; // rendering context HWND hWindow; // used if pWindow==NULL HDC hDC; // device context handle @@ -118,7 +118,7 @@ public: // Surface bool PrepareRendering(C4Surface * sfcToSurface); // check if/make rendering possible to given surface virtual CStdGLCtx *CreateContext(C4Window * pWindow, C4AbstractApp *pApp); -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS virtual CStdGLCtx *CreateContext(HWND hWindow, C4AbstractApp *pApp); #endif // Blit diff --git a/src/platform/StdGLCtx.cpp b/src/platform/StdGLCtx.cpp index c799aeae0..21f681215 100644 --- a/src/platform/StdGLCtx.cpp +++ b/src/platform/StdGLCtx.cpp @@ -47,7 +47,7 @@ void CStdGLCtx::SelectCommon() //glEnable(GL_POINT_SMOOTH); } -#ifdef _WIN32 +#ifdef USE_WIN32_WINDOWS #include diff --git a/src/platform/StdScheduler.cpp b/src/platform/StdScheduler.cpp index 646a9ee27..345a8eb65 100644 --- a/src/platform/StdScheduler.cpp +++ b/src/platform/StdScheduler.cpp @@ -23,7 +23,6 @@ #include "C4Include.h" #include "StdScheduler.h" -#include #include #include diff --git a/src/script/C4Aul.cpp b/src/script/C4Aul.cpp index 1cf74a547..f2d8a6016 100644 --- a/src/script/C4Aul.cpp +++ b/src/script/C4Aul.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include C4AulError::C4AulError(): shown(false) {}