diff --git a/SConscript b/SConscript index 8418fb57d..e2f74233c 100644 --- a/SConscript +++ b/SConscript @@ -242,26 +242,25 @@ def findLibs(env, conf): if not GetOption('renderer') and not conf.CheckLib('SDLmain'): FatalError("libSDLmain not found or not installed") - if not GetOption('renderer'): - #Look for SDL - runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD" - if False and platform == "Darwin" and conf.CheckFramework("SDL"): - runSdlConfig = False - elif not conf.CheckLib("SDL2"): - FatalError("SDL development library not found or not installed") + #Look for SDL + runSdlConfig = platform == "Linux" or compilePlatform == "Linux" or platform == "FreeBSD" + if False and platform == "Darwin" and conf.CheckFramework("SDL"): + runSdlConfig = False + elif not conf.CheckLib("SDL2"): + FatalError("SDL development library not found or not installed") - if runSdlConfig: - try: - env.ParseConfig('sdl2-config --cflags') - if GetOption('static'): - env.ParseConfig('sdl2-config --static-libs') - else: - env.ParseConfig('sdl2-config --libs') - except: - pass + if runSdlConfig: + try: + env.ParseConfig('sdl2-config --cflags') + if GetOption('static'): + env.ParseConfig('sdl2-config --static-libs') + else: + env.ParseConfig('sdl2-config --libs') + except: + pass #look for SDL.h - if not GetOption('renderer') and not conf.CheckCHeader('SDL2.h'): + if not conf.CheckCHeader('SDL2.h'): if conf.CheckCHeader('SDL2/SDL.h'): env.Append(CPPDEFINES=["SDL_INC"]) else: @@ -505,8 +504,6 @@ if GetOption('opengl') or GetOption('opengl-renderer'): if GetOption('renderer'): env.Append(CPPDEFINES=['RENDERER']) -else: - env.Append(CPPDEFINES=['USE_SDL']) if GetOption('font'): env.Append(CPPDEFINES=['FONTEDITOR']) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index a114937b1..89c3e9c9c 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -1,11 +1,10 @@ -#ifdef USE_SDL +#ifndef RENDERER #include #include "common/String.h" #include #include #ifdef WIN -#define _WIN32_WINNT 0x0501 //Necessary for some macros and functions, tells windows.h to include functions only available in Windows XP or later #include #endif #include "SDLCompat.h" @@ -54,10 +53,6 @@ using namespace std; #define INCLUDE_SYSWM #include "SDLCompat.h" -#if defined(USE_SDL) && defined(LIN) && defined(SDL_VIDEO_DRIVER_X11) -SDL_SysWMinfo sdl_wminfo; -Atom XA_CLIPBOARD, XA_TARGETS, XA_UTF8_STRING; -#endif int desktopWidth = 1280, desktopHeight = 1024; @@ -134,10 +129,7 @@ void blit(pixel * vid) int SDLOpen() { -#if defined(WIN) && defined(WINCONSOLE) - FILE * console = fopen("CON", "w" ); -#endif - if (SDL_Init(SDL_INIT_VIDEO)<0) + if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError()); return 1; @@ -148,32 +140,6 @@ int SDLOpen() desktopWidth = SDLDisplayMode.w; desktopHeight = SDLDisplayMode.h; -#if defined(WIN) && defined(WINCONSOLE) - //On Windows, SDL redirects stdout to stdout.txt, which can be annoying when debugging, here we redirect back to the console - if (console) - { - freopen("CON", "w", stdout); - freopen("CON", "w", stderr); - //fclose(console); - } -#endif -#ifdef WIN - SDL_SysWMinfo SysInfo; - SDL_VERSION(&SysInfo.version); - if(SDL_GetWMInfo(&SysInfo) <= 0) { - printf("%s : %p\n", SDL_GetError(), SysInfo.window); - exit(-1); - } - HWND WindowHandle = SysInfo.window; - - // Use GetModuleHandle to get the Exe HMODULE/HINSTANCE - HMODULE hModExe = GetModuleHandle(NULL); - HICON hIconSmall = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_SHARED); - HICON hIconBig = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_SHARED); - SendMessage(WindowHandle, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall); - SendMessage(WindowHandle, WM_SETICON, ICON_BIG, (LPARAM)hIconBig); -#endif - sdl_window = SDL_CreateWindow("The Powder Toy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOWW * scale, WINDOWH * scale, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); sdl_renderer = SDL_CreateRenderer(sdl_window, -1, 0); @@ -187,6 +153,23 @@ int SDLOpen() //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); //SDL_SetWindowResizable(sdl_window, SDL_TRUE); +#ifdef WIN + SDL_SysWMinfo SysInfo; + SDL_VERSION(&SysInfo.version); + if(SDL_GetWindowWMInfo(sdl_window, &SysInfo) <= 0) + { + printf("%s : %p\n", SDL_GetError(), SysInfo.info.win.window); + exit(-1); + } + HWND WindowHandle = SysInfo.info.win.window; + + // Use GetModuleHandle to get the Exe HMODULE/HINSTANCE + HMODULE hModExe = GetModuleHandle(NULL); + HICON hIconSmall = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 16, 16, LR_SHARED); + HICON hIconBig = (HICON)LoadImage(hModExe, MAKEINTRESOURCE(101), IMAGE_ICON, 32, 32, LR_SHARED); + SendMessage(WindowHandle, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall); + SendMessage(WindowHandle, WM_SETICON, ICON_BIG, (LPARAM)hIconBig); +#endif #ifdef LIN SDL_Surface *icon = SDL_CreateRGBSurfaceFrom((void*)app_icon, 48, 48, 32, 192, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); SDL_SetWindowIcon(sdl_window, icon); @@ -412,9 +395,6 @@ void DoubleScreenDialog() { Client::Ref().SetPref("Scale", 1); engine->SetScale(1); -#ifdef WIN - LoadWindowPosition(1); -#endif } } diff --git a/src/SDLCompat.cpp b/src/SDLCompat.cpp index 32c3f3adc..2e57a071c 100644 --- a/src/SDLCompat.cpp +++ b/src/SDLCompat.cpp @@ -1,4 +1,4 @@ -#if defined(USE_SDL) && defined(_MSC_VER) && (_MSC_VER >= 1900) +#if defined(_MSC_VER) && (_MSC_VER >= 1900) #include diff --git a/src/SDLCompat.h b/src/SDLCompat.h index c330c0911..3ae486eac 100644 --- a/src/SDLCompat.h +++ b/src/SDLCompat.h @@ -1,5 +1,3 @@ -#ifdef USE_SDL - #ifdef SDL_INC #include "SDL2/SDL.h" #else @@ -7,13 +5,11 @@ #endif #ifdef INCLUDE_SYSWM -#if defined(WIN) || defined(LIN) +#if defined(WIN) #ifdef SDL_INC #include #else #include #endif -#endif // WIN || LIN +#endif // WIN #endif // INCLUDE_SYSWM - -#endif // USE_SDL diff --git a/src/gui/localbrowser/LocalBrowserView.cpp b/src/gui/localbrowser/LocalBrowserView.cpp index 703dd9213..7f7971009 100644 --- a/src/gui/localbrowser/LocalBrowserView.cpp +++ b/src/gui/localbrowser/LocalBrowserView.cpp @@ -114,21 +114,17 @@ void LocalBrowserView::textChanged() else if (num > pageCount) pageTextbox->SetText(String::Build(pageCount)); changed = true; -#ifdef USE_SDL lastChanged = GetTicks()+600; -#endif } void LocalBrowserView::OnTick(float dt) { c->Update(); -#ifdef USE_SDL if (changed && lastChanged < GetTicks()) { changed = false; c->SetPage(std::max(pageTextbox->GetText().ToNumber(true), 0)); } -#endif } void LocalBrowserView::NotifyPageChanged(LocalBrowserModel * sender) diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index 810df3085..8ffdbadc1 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -180,13 +180,7 @@ OptionsView::OptionsView(): FullscreenAction(OptionsView * v_){ v = v_; } virtual void ActionCallback(ui::Checkbox * sender) { -#ifdef USE_SDL -#if defined(MACOSX) && !SDL_VERSION_ATLEAST(1, 2, 15) - ErrorMessage::Blocking("Information", "Fullscreen doesn't work on OS X"); -#else v->c->SetFullscreen(sender->GetChecked()); -#endif -#endif } }; diff --git a/src/gui/search/SearchView.cpp b/src/gui/search/SearchView.cpp index 245b256a5..94c6cb511 100644 --- a/src/gui/search/SearchView.cpp +++ b/src/gui/search/SearchView.cpp @@ -291,9 +291,7 @@ void SearchView::textChanged() else if (num > pageCount) pageTextbox->SetText(String::Build(pageCount)); changed = true; -#ifdef USE_SDL lastChanged = GetTicks()+600; -#endif } void SearchView::OnTryOkay(OkayMethod method) @@ -780,13 +778,11 @@ void SearchView::NotifySelectedChanged(SearchModel * sender) void SearchView::OnTick(float dt) { c->Update(); -#ifdef USE_SDL if (changed && lastChanged < GetTicks()) { changed = false; c->SetPage(std::max(pageTextbox->GetText().ToNumber(true), 0)); } -#endif } void SearchView::OnMouseWheel(int x, int y, int d)