Skip to content

Commit

Permalink
Merge pull request #627 from aginor/remove_sdl_1.2
Browse files Browse the repository at this point in the history
Remove SDL 1.2 support from Wesnoth
  • Loading branch information
aginor committed Mar 12, 2016
2 parents 1279214 + 1d56fbb commit 8da954b
Show file tree
Hide file tree
Showing 82 changed files with 44 additions and 3,799 deletions.
42 changes: 9 additions & 33 deletions CMakeLists.txt
Expand Up @@ -49,7 +49,6 @@ option(ENABLE_CAMPAIGN_SERVER "Enable compilation of campaign server")
option(ENABLE_SERVER "Enable compilation of server" ON)
option(ENABLE_TOOLS "Enable building and installation of tools for artists and WML maintainers")
option(ENABLE_SDL2_TOOLS "Enable building and installation of tools for testing with SDL2" OFF)
option(ENABLE_SDL2 "Enable building the game with SDL2" ON)
option(ENABLE_TESTS "Build unit tests")
option(ENABLE_NLS "Enable building of translations" ON)
option(ENABLE_LOW_MEM "Reduce memory usage by removing extra functionality" OFF)
Expand All @@ -60,15 +59,12 @@ option(ENABLE_LIBPNG "Enable support for writing png files (screenshots, images)
option(ENABLE_LIBINTL "Enable using libintl for translations instead of Boost.Locale library (not recommended)" OFF)
option(ENABLE_HISTORY "Enable using GNU history for history in lua console" ON)

if(ENABLE_SDL2)

if(UNIX AND NOT APPLE AND NOT CYGWIN)
find_package(SDL2 2.0.2 REQUIRED)
else (UNIX AND NOT APPLE AND NOT CYGWIN)
find_package(SDL2 2.0.4 REQUIRED)
endif (UNIX AND NOT APPLE AND NOT CYGWIN)
else(ENABLE_SDL2)
find_package(SDL 1.2.7 REQUIRED)
endif(ENABLE_SDL2)

find_package(Boost 1.36 REQUIRED COMPONENTS iostreams program_options regex system)
find_package(Boost 1.40 REQUIRED COMPONENTS random)
Expand All @@ -79,17 +75,10 @@ find_package(Gettext)
find_package(X11)

if(NOT MSVC)
if(ENABLE_SDL2)
#needed to get some SDL2 defines in... (as of rev31694 -D_GNU_SOURCE=1 is required!)
set(SDL2_CONFIG "sdl2-config" CACHE STRING "Path to sdl2-config script")
exec_program(${SDL2_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE SDL2_CFLAGS)
add_definitions(${SDL2_CFLAGS})
else(ENABLE_SDL2)
#needed to get some SDL defines in... (as of rev31694 -D_GNU_SOURCE=1 is required!)
set(SDL_CONFIG "sdl-config" CACHE STRING "Path to sdl-config script")
exec_program(${SDL_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE SDL_CFLAGS)
add_definitions(${SDL_CFLAGS})
endif(ENABLE_SDL2)
#needed to get some SDL2 defines in... (as of rev31694 -D_GNU_SOURCE=1 is required!)
set(SDL2_CONFIG "sdl2-config" CACHE STRING "Path to sdl2-config script")
exec_program(${SDL2_CONFIG} ARGS "--cflags" OUTPUT_VARIABLE SDL2_CFLAGS)
add_definitions(${SDL2_CFLAGS})
endif(NOT MSVC)

if(NOT WIN32)
Expand Down Expand Up @@ -570,20 +559,11 @@ endif(ENABLE_DEBUG_WINDOW_LAYOUT)
#

if(ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_TESTS)
if(ENABLE_SDL2)
find_package( SDL2_image 2.0.0 REQUIRED )
else(ENABLE_SDL2)
find_package( SDL_image 1.2 REQUIRED )
endif(ENABLE_SDL2)
find_package( SDL2_image 2.0.0 REQUIRED )
endif(ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_TESTS)
if(ENABLE_GAME OR ENABLE_TESTS)
if(ENABLE_SDL2)
find_package( SDL2_mixer 2.0.0 REQUIRED )
find_package( SDL2_ttf 2.0.8 REQUIRED )
else(ENABLE_SDL2)
find_package( SDL_mixer 1.2.12 REQUIRED )
find_package( SDL_ttf 2.0.8 REQUIRED )
endif(ENABLE_SDL2)
find_package( SDL2_mixer 2.0.0 REQUIRED )
find_package( SDL2_ttf 2.0.8 REQUIRED )
if(NOT MSVC)
find_package(VorbisFile REQUIRED)
find_package( PkgConfig REQUIRED )
Expand All @@ -594,11 +574,7 @@ if(ENABLE_GAME OR ENABLE_TESTS)

endif(ENABLE_GAME OR ENABLE_TESTS)
if(ENABLE_GAME OR ENABLE_SERVER OR ENABLE_CAMPAIGN_SERVER OR ENABLE_TESTS)
if(ENABLE_SDL2)
find_package( SDL2_net 2.0.0 REQUIRED )
else(ENABLE_SDL2)
find_package( SDL_net REQUIRED )
endif(ENABLE_SDL2)
find_package( SDL2_net 2.0.0 REQUIRED )
endif(ENABLE_GAME OR ENABLE_SERVER OR ENABLE_CAMPAIGN_SERVER OR ENABLE_TESTS)
if(ENABLE_TOOLS)
find_package( ZLIB REQUIRED )
Expand Down
37 changes: 12 additions & 25 deletions SConstruct
Expand Up @@ -108,8 +108,7 @@ opts.AddVariables(
BoolVariable("fast", "Make scons faster at cost of less precise dependency tracking.", False),
BoolVariable("lockfile", "Create a lockfile to prevent multiple instances of scons from being run at the same time on this working copy.", False),
BoolVariable("OS_ENV", "Forward the entire OS environment to scons", False),
BoolVariable("history", "Clear to disable GNU history support in lua console", True),
BoolVariable("sdl2", "Build with SDL2 support (experimental!)", True)
BoolVariable("history", "Clear to disable GNU history support in lua console", True)
)

#
Expand Down Expand Up @@ -364,31 +363,19 @@ if env["prereqs"]:
conf.CheckLib("vorbis")
conf.CheckLib("mikmod")

if env['sdl2']:
def have_sdl_net():
return \
conf.CheckSDL(require_version = SDL2_version) & \
conf.CheckSDL("SDL2_net", header_file = "SDL_net")

def have_sdl_other():
return \
conf.CheckSDL(require_version = SDL2_version) & \
conf.CheckSDL("SDL2_ttf", header_file = "SDL_ttf") & \
conf.CheckSDL("SDL2_mixer", header_file = "SDL_mixer") & \
conf.CheckSDL("SDL2_image", header_file = "SDL_image")
def have_sdl_net():
return \
conf.CheckSDL(require_version = SDL2_version) & \
conf.CheckSDL("SDL2_net", header_file = "SDL_net")

def have_sdl_other():
return \
conf.CheckSDL(require_version = SDL2_version) & \
conf.CheckSDL("SDL2_ttf", header_file = "SDL_ttf") & \
conf.CheckSDL("SDL2_mixer", header_file = "SDL_mixer") & \
conf.CheckSDL("SDL2_image", header_file = "SDL_image")

else:
def have_sdl_net():
return \
conf.CheckSDL(require_version = '1.2.10') & \
conf.CheckSDL('SDL_net')

def have_sdl_other():
return \
conf.CheckSDL(require_version = '1.2.10') & \
conf.CheckSDL("SDL_ttf", require_version = "2.0.8") & \
conf.CheckSDL("SDL_mixer", require_version = '1.2.12') & \
conf.CheckSDL("SDL_image", require_version = '1.2.0')

if env["libintl"]:
def have_i18n_prereqs():
Expand Down
8 changes: 0 additions & 8 deletions projectfiles/VC9/wesnoth.vcproj
Expand Up @@ -22298,14 +22298,6 @@
RelativePath="..\..\src\sdl\image.hpp"
>
</File>
<File
RelativePath="..\..\src\sdl\keyboard.cpp"
>
</File>
<File
RelativePath="..\..\src\sdl\keyboard.hpp"
>
</File>
<File
RelativePath="..\..\src\sdl\rect.cpp"
>
Expand Down
6 changes: 0 additions & 6 deletions projectfiles/Xcode/Mac Sources/SDLMain.m
Expand Up @@ -7,9 +7,7 @@
#import "SDL.h"
#import "SDLMain.h"

#if SDL_VERSION_ATLEAST(2, 0, 0)
extern int wesnoth_main(int argc, char **argv);
#endif
static int gArgc;
static char **gArgv;

Expand Down Expand Up @@ -75,11 +73,7 @@ - (void) applicationDidFinishLaunching: (NSNotification *) note
//setenv("PYTHONHOME", ".", 1); //not needed because we don't use Python anymore

/* Hand off to main application code */
#if SDL_VERSION_ATLEAST(2, 0, 0)
status = wesnoth_main (gArgc, gArgv);
#else
status = SDL_main (gArgc, gArgv);
#endif

/* We're done, thank you for playing */
exit(status);
Expand Down
65 changes: 21 additions & 44 deletions src/CMakeLists.txt
Expand Up @@ -21,49 +21,27 @@ include_directories(SYSTEM ${LIBDBUS_INCLUDE_DIRS} )
include_directories(SYSTEM ${LIBINTL_INCLUDE_DIR} )
include_directories(SYSTEM ${VORBISFILE_INCLUDE_DIR} )

if(ENABLE_SDL2)
include_directories(SYSTEM ${SDL2_INCLUDE_DIR} )
set(sdl-lib ${SDL2_LIBRARY})
set(sdlmain-lib ${SDL2MAIN_LIBRARY})
#optional dependencies
if(SDL2IMAGE_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2IMAGE_INCLUDE_DIR} )
set(sdl_image-lib ${SDL2_IMAGE_LIBRARY})
endif()
if(SDL2MIXER_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2MIXER_INCLUDE_DIR} )
set(sdl_mixer-lib ${SDL2_MIXER_LIBRARY})
endif()
if(SDL2NET_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2NET_INCLUDE_DIR} )
set(sdl_net-lib ${SDL2_NET_LIBRARY})
endif()
if(SDL2TTF_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2TTF_INCLUDE_DIR} )
set(sdl_ttf-lib ${SDL2_TTF_LIBRARY})
endif()
else(ENABLE_SDL2)
include_directories(SYSTEM ${SDL_INCLUDE_DIR} )
set(sdl-lib ${SDL_LIBRARY})
set(sdlmain-lib ${SDLMAIN_LIBRARY})
#optional dependencies
if(SDLIMAGE_INCLUDE_DIR)
include_directories(SYSTEM ${SDLIMAGE_INCLUDE_DIR} )
set(sdl_image-lib ${SDLIMAGE_LIBRARY})
endif()
if(SDLMIXER_INCLUDE_DIR)
include_directories(SYSTEM ${SDLMIXER_INCLUDE_DIR} )
set(sdl_mixer-lib ${SDLMIXER_LIBRARY})
endif()
if(SDLNET_INCLUDE_DIR)
include_directories(SYSTEM ${SDLNET_INCLUDE_DIR} )
set(sdl_net-lib ${SDLNET_LIBRARY})
endif()
if(SDLTTF_INCLUDE_DIR)
include_directories(SYSTEM ${SDLTTF_INCLUDE_DIR} )
set(sdl_ttf-lib ${SDLTTF_LIBRARY})
endif()
endif(ENABLE_SDL2)

include_directories(SYSTEM ${SDL2_INCLUDE_DIR} )
set(sdl-lib ${SDL2_LIBRARY})
set(sdlmain-lib ${SDL2MAIN_LIBRARY})
#optional dependencies
if(SDL2IMAGE_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2IMAGE_INCLUDE_DIR} )
set(sdl_image-lib ${SDL2_IMAGE_LIBRARY})
endif()
if(SDL2MIXER_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2MIXER_INCLUDE_DIR} )
set(sdl_mixer-lib ${SDL2_MIXER_LIBRARY})
endif()
if(SDL2NET_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2NET_INCLUDE_DIR} )
set(sdl_net-lib ${SDL2_NET_LIBRARY})
endif()
if(SDL2TTF_INCLUDE_DIR)
include_directories(SYSTEM ${SDL2TTF_INCLUDE_DIR} )
set(sdl_ttf-lib ${SDL2_TTF_LIBRARY})
endif()

if(ZLIB_INCLUDE_DIR)
include_directories(SYSTEM ${ZLIB_INCLUDE_DIR} )
Expand Down Expand Up @@ -450,7 +428,6 @@ set(wesnoth-sdl_SRC
sdl/window.cpp
sdl/utils.cpp
sdl/shader.cpp
sdl/keyboard.cpp
xBRZ/xbrz.cpp
)

Expand Down
1 change: 0 additions & 1 deletion src/SConscript
Expand Up @@ -171,7 +171,6 @@ libwesnoth_sdl_sources = Split("""
sdl/exception.cpp
sdl/rect.cpp
sdl/image.cpp
sdl/keyboard.cpp
sdl/window.cpp
tracer.cpp
xBRZ/xbrz.cpp
Expand Down
2 changes: 0 additions & 2 deletions src/SDL_gpu/SDL_gpu/SDL_gpu.h
Expand Up @@ -16,9 +16,7 @@ extern "C" {
#define SDL_GPU_VERSION_PATCH 0

/* Auto-detect if we're using the SDL2 API by the headers available. */
#if SDL_VERSION_ATLEAST(2,0,0)
#define SDL_GPU_USE_SDL2
#endif

typedef struct GPU_Renderer GPU_Renderer;
typedef struct GPU_Target GPU_Target;
Expand Down
5 changes: 0 additions & 5 deletions src/about.cpp
Expand Up @@ -44,12 +44,7 @@
#include <map> // for map, map<>::mapped_type
#include <ostream> // for operator<<, basic_ostream, etc

#if !SDL_VERSION_ATLEAST(2,0,0)
#include "SDL_keysym.h" // for ::SDLK_ESCAPE, ::SDLK_DOWN, etc
#include "SDL_video.h" // for SDL_Rect, SDL_Surface, etc
#else
#include "sdl/alpha.hpp"
#endif

/**
* @namespace about
Expand Down
14 changes: 0 additions & 14 deletions src/attack_prediction_display.cpp
Expand Up @@ -504,7 +504,6 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<

int bar_len = std::max<int>(static_cast<int>((prob * (bar_space - 4)) + 0.5), 2);

#if SDL_VERSION_ATLEAST(2,0,0)
SDL_Rect bar_rect_1 = sdl::create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
sdl::fill_rect(surf, &bar_rect_1, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.a, 100));

Expand All @@ -516,19 +515,6 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<

SDL_Rect bar_rect_4 = sdl::create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
sdl::fill_rect(surf, &bar_rect_4, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.a, 0));
#else
SDL_Rect bar_rect_1 = sdl::create_rect(hp_sep + 4, 6 + (fs + 2) * i, bar_len, 8);
sdl::fill_rect(surf, &bar_rect_1, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.unused, 100));

SDL_Rect bar_rect_2 = sdl::create_rect(hp_sep + 4, 7 + (fs + 2) * i, bar_len, 6);
sdl::fill_rect(surf, &bar_rect_2, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.unused, 66));

SDL_Rect bar_rect_3 = sdl::create_rect(hp_sep + 4, 8 + (fs + 2) * i, bar_len, 4);
sdl::fill_rect(surf, &bar_rect_3, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.unused, 33));

SDL_Rect bar_rect_4 = sdl::create_rect(hp_sep + 4, 9 + (fs + 2) * i, bar_len, 2);
sdl::fill_rect(surf, &bar_rect_4, blend_rgba(surf, row_color.r, row_color.g, row_color.b, row_color.unused, 0));
#endif

// Draw probability percentage, aligned right.
format_prob(str_buf, prob);
Expand Down
7 changes: 0 additions & 7 deletions src/build_info.cpp
Expand Up @@ -81,15 +81,8 @@ version_table_manager::version_table_manager()
SDL_VERSION(&sdl_version);
compiled[LIB_SDL] = format_version(sdl_version);

#if SDL_VERSION_ATLEAST(2,0,0)
SDL_GetVersion(&sdl_version);
linked[LIB_SDL] = format_version(sdl_version);
#else
sdl_rt_version = SDL_Linked_Version();
if(sdl_rt_version) {
linked[LIB_SDL] = format_version(*sdl_rt_version);
}
#endif

names[LIB_SDL] = "SDL";

Expand Down
18 changes: 0 additions & 18 deletions src/controller_base.cpp
Expand Up @@ -105,27 +105,9 @@ void controller_base::handle_event(const SDL_Event& event)
show_menu(get_display().get_theme().context_menu()->items(),event.button.x,event.button.y,true, get_display());
}
break;
#if !SDL_VERSION_ATLEAST(2, 0, 0)
case SDL_ACTIVEEVENT:
if (event.active.state == SDL_APPMOUSEFOCUS && event.active.gain == 0) {
if (get_mouse_handler_base().is_dragging()) {
//simulate mouse button up when the app has lost mouse focus
//this should be a general fix for the issue when the mouse
//is dragged out of the game window and then the button is released
int x, y;
Uint8 mouse_flags = SDL_GetMouseState(&x, &y);
if ((mouse_flags & SDL_BUTTON_LEFT) == 0) {
get_mouse_handler_base().mouse_press(event.button, is_browsing());
}
}
}
break;
#endif
#if SDL_VERSION_ATLEAST(2,0,0)
case SDL_MOUSEWHEEL:
get_mouse_handler_base().mouse_wheel(event.wheel.x, event.wheel.y, is_browsing());
break;
#endif
default:
break;
}
Expand Down
2 changes: 0 additions & 2 deletions src/controller_base.hpp
Expand Up @@ -114,9 +114,7 @@ class controller_base : public video2::draw_layering
*/
void handle_event(const SDL_Event& event);

#if SDL_VERSION_ATLEAST(2, 0, 0)
void handle_window_event(const SDL_Event& ) {}
#endif

/**
* Process keydown (only when the general map display does not have focus).
Expand Down

0 comments on commit 8da954b

Please sign in to comment.