Merge lp:~widelands-dev/widelands/SDL2 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7242
Proposed branch: lp:~widelands-dev/widelands/SDL2
Merge into: lp:widelands
Diff against target: 4248 lines (+1245/-854)
94 files modified
CMakeLists.txt (+6/-6)
CREDITS (+6/-6)
cmake/Modules/FindSDL.cmake (+0/-186)
cmake/Modules/FindSDL2.cmake (+190/-0)
cmake/Modules/FindSDL2_gfx.cmake (+60/-0)
cmake/Modules/FindSDL2_image.cmake (+88/-0)
cmake/Modules/FindSDL2_mixer.cmake (+88/-0)
cmake/Modules/FindSDL2_net.cmake (+88/-0)
cmake/Modules/FindSDL2_ttf.cmake (+88/-0)
cmake/Modules/FindSDL_gfx.cmake (+0/-64)
cmake/WlFunctions.cmake (+38/-38)
cmake/codecheck/rules/correct_include_order (+4/-4)
src/CMakeLists.txt (+4/-4)
src/base/CMakeLists.txt (+1/-1)
src/editor/CMakeLists.txt (+1/-1)
src/editor/editorinteractive.cc (+12/-12)
src/editor/editorinteractive.h (+1/-1)
src/editor/ui_menus/categorized_item_selection_menu.h (+1/-1)
src/editor/ui_menus/editor_main_menu_load_map.cc (+1/-0)
src/editor/ui_menus/editor_main_menu_save_map.cc (+1/-0)
src/editor/ui_menus/editor_tool_place_bob_options_menu.cc (+2/-2)
src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc (+1/-1)
src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc (+1/-1)
src/graphic/CMakeLists.txt (+10/-10)
src/graphic/font_handler.cc (+1/-1)
src/graphic/gl/surface_texture.cc (+5/-3)
src/graphic/graphic.cc (+121/-117)
src/graphic/graphic.h (+9/-13)
src/graphic/image_transformations.cc (+3/-2)
src/graphic/sdl/surface.cc (+8/-4)
src/graphic/sdl/surface.h (+2/-0)
src/graphic/surface.cc (+1/-1)
src/graphic/text/CMakeLists.txt (+3/-3)
src/graphic/text/sdl_ttf_font.cc (+5/-3)
src/io/CMakeLists.txt (+1/-1)
src/logic/CMakeLists.txt (+3/-3)
src/map_io/CMakeLists.txt (+1/-1)
src/network/CMakeLists.txt (+1/-1)
src/sound/CMakeLists.txt (+2/-2)
src/sound/songset.cc (+3/-19)
src/sound/sound_handler.cc (+2/-5)
src/ui_basic/CMakeLists.txt (+1/-1)
src/ui_basic/button.cc (+1/-0)
src/ui_basic/editbox.cc (+21/-51)
src/ui_basic/editbox.h (+2/-2)
src/ui_basic/is_printable.cc (+2/-3)
src/ui_basic/is_printable.h (+1/-1)
src/ui_basic/listselect.cc (+13/-8)
src/ui_basic/listselect.h (+2/-1)
src/ui_basic/messagebox.cc (+2/-2)
src/ui_basic/messagebox.h (+1/-1)
src/ui_basic/multilineeditbox.cc (+26/-41)
src/ui_basic/multilineeditbox.h (+3/-3)
src/ui_basic/multilinetextarea.cc (+3/-6)
src/ui_basic/multilinetextarea.h (+1/-1)
src/ui_basic/panel.cc (+116/-28)
src/ui_basic/panel.h (+19/-7)
src/ui_basic/progresswindow.cc (+2/-2)
src/ui_basic/scrollbar.cc (+10/-16)
src/ui_basic/scrollbar.h (+2/-1)
src/ui_basic/table.cc (+10/-8)
src/ui_basic/table.h (+4/-2)
src/ui_basic/window.cc (+2/-2)
src/ui_fsmenu/intro.cc (+1/-1)
src/ui_fsmenu/intro.h (+1/-1)
src/ui_fsmenu/load_map_or_game.cc (+2/-2)
src/ui_fsmenu/load_map_or_game.h (+1/-1)
src/ui_fsmenu/loadgame.cc (+2/-2)
src/ui_fsmenu/loadgame.h (+1/-1)
src/ui_fsmenu/options.cc (+18/-21)
src/ui_fsmenu/options.h (+3/-2)
src/wlapplication.cc (+34/-57)
src/wlapplication.h (+4/-2)
src/wui/CMakeLists.txt (+1/-1)
src/wui/actionconfirm.cc (+1/-1)
src/wui/building_statistics_menu.cc (+1/-0)
src/wui/buildingwindow.cc (+3/-3)
src/wui/encyclopedia_window.cc (+1/-0)
src/wui/fieldaction.cc (+4/-4)
src/wui/game_message_menu.cc (+3/-2)
src/wui/game_message_menu.h (+1/-1)
src/wui/game_options_menu.cc (+1/-1)
src/wui/game_tips.cc (+1/-1)
src/wui/interactive_base.cc (+19/-11)
src/wui/interactive_base.h (+2/-2)
src/wui/interactive_player.cc (+3/-3)
src/wui/interactive_player.h (+1/-1)
src/wui/interactive_spectator.cc (+2/-2)
src/wui/interactive_spectator.h (+1/-1)
src/wui/mapview.cc (+1/-1)
src/wui/quicknavigation.cc (+3/-3)
src/wui/quicknavigation.h (+1/-1)
src/wui/shipwindow.cc (+2/-2)
utils/macos/build_app.sh (+19/-19)
To merge this branch: bzr merge lp:~widelands-dev/widelands/SDL2
Reviewer Review Type Date Requested Status
SirVer Pending
Review via email: mp+239865@code.launchpad.net

Description of the change

As discussed in the bug, this is done for merging.

I still have 3 NOCOM comments in the code that need checking out by a Mac user.

To post a comment you must log in.
Revision history for this message
Hans Joachim Desserud (hjd) wrote :

Just to check, this makes Widelands SDL2-only, right? (No fallback to SDL1)
I don't have any strong opinions on this, and it's probably ok since SDL2 is already available in the latest versions of most (all) distros. :)

However, this means that we need to update the list of dependencies in the PPA to point to SDL2 packages instead. This is fine for Ubuntu 14.04 and later where SDL2 is packaged, but it might mean the end of the line for our 12.04 PPA unless we wish to backport SDL2 as well. We are already backporting the GCC-version used, and I thought that was somewhat excessive.

I can prepare a test build of this branch packaged with SDL2-packages.

Revision history for this message
SirVer (sirver) wrote :

Yes, no fallback for SDL. That is excessive maintenance. I am fine with retiring our 12.04 PPA, but I think we should hard delete it - not that people are expecting nightlies and we cannot deliver them - better to give them an error message then old packages.

Please try to set up a PPA with the SDL2 packages.

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

>I can prepare a test build of this branch packaged with SDL2-packages.
Built, installed tested. It just works(tm)
https://code.launchpad.net/~widelands-dev/widelands/debian-sdl2-packages/+merge/239904

>Yes, no fallback for SDL. That is excessive maintenance.

That's understandable. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-10-16 04:54:10 +0000
3+++ CMakeLists.txt 2014-11-02 20:06:40 +0000
4@@ -51,12 +51,12 @@
5 find_package(Gettext REQUIRED)
6 find_package(OpenGL REQUIRED)
7 find_package(PNG REQUIRED)
8-find_package(SDL REQUIRED)
9-find_package(SDL_gfx REQUIRED)
10-find_package(SDL_image REQUIRED)
11-find_package(SDL_mixer REQUIRED)
12-find_package(SDL_net REQUIRED)
13-find_package(SDL_ttf REQUIRED)
14+find_package(SDL2 REQUIRED)
15+find_package(SDL2_gfx REQUIRED)
16+find_package(SDL2_image REQUIRED)
17+find_package(SDL2_mixer REQUIRED)
18+find_package(SDL2_net REQUIRED)
19+find_package(SDL2_ttf REQUIRED)
20 find_package(ZLIB REQUIRED)
21
22 if (APPLE OR WIN32 OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
23
24=== modified file 'CREDITS'
25--- CREDITS 2014-07-14 10:45:44 +0000
26+++ CREDITS 2014-11-02 20:06:40 +0000
27@@ -8,12 +8,12 @@
28
29 The Widelands Development Team thanks the following projects:
30
31- libSDL
32- libSDL_mixer
33- libSDL_net
34- libSDL_image
35- libSDL_ttf
36- * All files from SDL-Project
37+ libSDL2
38+ libSDL2_mixer
39+ libSDL2_net
40+ libSDL2_image
41+ libSDL2_ttf
42+ * All files from SDL2-Project
43 * Project can be found at http://www.libsdl.org/
44
45
46
47=== removed file 'cmake/Modules/FindSDL.cmake'
48--- cmake/Modules/FindSDL.cmake 2010-03-28 19:12:31 +0000
49+++ cmake/Modules/FindSDL.cmake 1970-01-01 00:00:00 +0000
50@@ -1,186 +0,0 @@
51-# Locate SDL library
52-# This module defines
53-# SDL_LIBRARY, the name of the library to link against
54-# SDL_FOUND, if false, do not try to link to SDL
55-# SDL_INCLUDE_DIR, where to find SDL.h
56-#
57-# This module responds to the the flag:
58-# SDL_BUILDING_LIBRARY
59-# If this is defined, then no SDL_main will be linked in because
60-# only applications need main().
61-# Otherwise, it is assumed you are building an application and this
62-# module will attempt to locate and set the the proper link flags
63-# as part of the returned SDL_LIBRARY variable.
64-#
65-# Don't forget to include SDLmain.h and SDLmain.m your project for the
66-# OS X framework based version. (Other versions link to -lSDLmain which
67-# this module will try to find on your behalf.) Also for OS X, this
68-# module will automatically add the -framework Cocoa on your behalf.
69-#
70-#
71-# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your configuration
72-# and no SDL_LIBRARY, it means CMake did not find your SDL library
73-# (SDL.dll, libsdl.so, SDL.framework, etc).
74-# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again.
75-# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value
76-# as appropriate. These values are used to generate the final SDL_LIBRARY
77-# variable, but when these values are unset, SDL_LIBRARY does not get created.
78-#
79-#
80-# $SDLDIR is an environment variable that would
81-# correspond to the ./configure --prefix=$SDLDIR
82-# used in building SDL.
83-# l.e.galup 9-20-02
84-#
85-# Modified by Eric Wing.
86-# Added code to assist with automated building by using environmental variables
87-# and providing a more controlled/consistent search behavior.
88-# Added new modifications to recognize OS X frameworks and
89-# additional Unix paths (FreeBSD, etc).
90-# Also corrected the header search path to follow "proper" SDL guidelines.
91-# Added a search for SDLmain which is needed by some platforms.
92-# Added a search for threads which is needed by some platforms.
93-# Added needed compile switches for MinGW.
94-#
95-# On OSX, this will prefer the Framework version (if found) over others.
96-# People will have to manually change the cache values of
97-# SDL_LIBRARY to override this selection or set the CMake environment
98-# CMAKE_INCLUDE_PATH to modify the search paths.
99-#
100-# Note that the header path has changed from SDL/SDL.h to just SDL.h
101-# This needed to change because "proper" SDL convention
102-# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
103-# reasons because not all systems place things in SDL/ (see FreeBSD).
104-
105-#=============================================================================
106-# Copyright 2003-2009 Kitware, Inc.
107-#
108-# Distributed under the OSI-approved BSD License (the "License");
109-# see accompanying file Copyright.txt for details.
110-#
111-# This software is distributed WITHOUT ANY WARRANTY; without even the
112-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
113-# See the License for more information.
114-#=============================================================================
115-# (To distributed this file outside of CMake, substitute the full
116-# License text for the above reference.)
117-
118-FIND_PATH(SDL_INCLUDE_DIR SDL.h
119- HINTS
120- $ENV{SDLDIR}
121- PATH_SUFFIXES include/SDL include
122- PATHS
123- ~/Library/Frameworks
124- /Library/Frameworks
125- /usr/local/include/SDL12
126- /usr/local/include/SDL11 # FreeBSD ports
127- /usr/include/SDL12
128- /usr/include/SDL11
129- /sw # Fink
130- /opt/local # DarwinPorts
131- /opt/csw # Blastwave
132- /opt
133- C:/MinGW #Win32
134-)
135-#MESSAGE("SDL_INCLUDE_DIR is ${SDL_INCLUDE_DIR}")
136-
137-# SDL-1.1 is the name used by FreeBSD ports...
138-# don't confuse it for the version number.
139-FIND_LIBRARY(SDL_LIBRARY_TEMP
140- NAMES SDL SDL-1.1
141- HINTS
142- $ENV{SDLDIR}
143- PATH_SUFFIXES lib64 lib
144- PATHS
145- /sw
146- /opt/local
147- /opt/csw
148- /opt
149- C:/MinGW
150-)
151-
152-#MESSAGE(STATUS "SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}")
153-
154-IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
155-# Non-OS X framework versions expect you to also dynamically link to
156-# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
157-# seem to provide SDLmain for compatibility even though they don't
158-# necessarily need it.
159-FIND_LIBRARY(SDLMAIN_LIBRARY
160- NAMES SDLmain SDLmain-1.1
161- HINTS
162- $ENV{SDLDIR}
163- PATH_SUFFIXES lib64 lib
164- PATHS
165- /sw
166- /opt/local
167- /opt/csw
168- /opt
169- C:/MinGW
170-)
171-ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
172-
173-MESSAGE(STATUS "SDLMAIN_LIBRARY is ${SDLMAIN_LIBRARY}")
174-
175-
176-# SDL may require threads on your system.
177-# The Apple build may not need an explicit flag because one of the
178-# frameworks may already provide it.
179-# But for non-OSX systems, I will use the CMake Threads package.
180-IF(NOT APPLE)
181- FIND_PACKAGE(Threads)
182-ENDIF(NOT APPLE)
183-
184-# MinGW needs an additional library, mwindows
185-# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
186-# (Actually on second look, I think it only needs one of the m* libraries.)
187-IF(MINGW)
188- SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
189-ENDIF(MINGW)
190-
191-SET(SDL_FOUND "NO")
192-IF(SDL_LIBRARY_TEMP)
193- # For SDLmain
194- IF(NOT SDL_BUILDING_LIBRARY)
195- IF(SDLMAIN_LIBRARY)
196- SET(SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY} ${SDL_LIBRARY_TEMP})
197- ENDIF(SDLMAIN_LIBRARY)
198- ENDIF(NOT SDL_BUILDING_LIBRARY)
199-
200- # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
201- # CMake doesn't display the -framework Cocoa string in the UI even
202- # though it actually is there if I modify a pre-used variable.
203- # I think it has something to do with the CACHE STRING.
204- # So I use a temporary variable until the end so I can set the
205- # "real" variable in one-shot.
206- IF(APPLE)
207- SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} "-framework Cocoa")
208- ENDIF(APPLE)
209-
210- # For threads, as mentioned Apple doesn't need this.
211- # In fact, there seems to be a problem if I used the Threads package
212- # and try using this line, so I'm just skipping it entirely for OS X.
213- IF(NOT APPLE)
214- SET(SDL_LIBRARY_TEMP ${SDL_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
215- ENDIF(NOT APPLE)
216-
217- # For MinGW library
218- IF(MINGW)
219- SET(SDL_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL_LIBRARY_TEMP})
220- ENDIF(MINGW)
221-
222- # Set the final string here so the GUI reflects the final state.
223- SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
224- # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
225- SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "")
226- IF(NOT SDLMAIN_LIBRARY)
227- IF(WIN32)
228- MESSAGE(FATAL_ERROR "$Could NOT find SDL (missing: SDLmain)")
229- ENDIF(WIN32)
230- ENDIF(NOT SDLMAIN_LIBRARY)
231-
232- SET(SDL_FOUND "YES")
233-ENDIF(SDL_LIBRARY_TEMP)
234-
235-#MESSAGE(STATUS "SDL_LIBRARY is ${SDL_LIBRARY}")
236-
237
238=== added file 'cmake/Modules/FindSDL2.cmake'
239--- cmake/Modules/FindSDL2.cmake 1970-01-01 00:00:00 +0000
240+++ cmake/Modules/FindSDL2.cmake 2014-11-02 20:06:40 +0000
241@@ -0,0 +1,190 @@
242+# Locate SDL2 library
243+# This module defines
244+# SDL2_LIBRARY, the name of the library to link against
245+# SDL2_FOUND, if false, do not try to link to SDL
246+# SDL2_INCLUDE_DIR, where to find SDL.h
247+#
248+# This module responds to the the flag:
249+# SDL2_BUILDING_LIBRARY
250+# If this is defined, then no SDL_main will be linked in because
251+# only applications need main().
252+# Otherwise, it is assumed you are building an application and this
253+# module will attempt to locate and set the the proper link flags
254+# as part of the returned SDL_LIBRARY variable.
255+#
256+# Don't forget to include SDLmain.h and SDLmain.m your project for the
257+# OS X framework based version. (Other versions link to -lSDL2main which
258+# this module will try to find on your behalf.) Also for OS X, this
259+# module will automatically add the -framework Cocoa on your behalf.
260+#
261+#
262+# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
263+# and no SDL2_LIBRARY, it means CMake did not find your SDL library
264+# (SDL.dll, libsdl.so, SDL.framework, etc).
265+# Set SDL_LIBRARY_TEMP to point to your SDL library, and configure again.
266+# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this value
267+# as appropriate. These values are used to generate the final SDL_LIBRARY
268+# variable, but when these values are unset, SDL_LIBRARY does not get created.
269+#
270+#
271+# $SDL2DIR is an environment variable that would
272+# correspond to the ./configure --prefix=$SDL2DIR
273+# used in building SDL.
274+# l.e.galup 9-20-02
275+#
276+# Modified by Eric Wing.
277+# Added code to assist with automated building by using environmental variables
278+# and providing a more controlled/consistent search behavior.
279+# Added new modifications to recognize OS X frameworks and
280+# additional Unix paths (FreeBSD, etc).
281+# Also corrected the header search path to follow "proper" SDL guidelines.
282+# Added a search for SDLmain which is needed by some platforms.
283+# Added a search for threads which is needed by some platforms.
284+# Added needed compile switches for MinGW.
285+#
286+# On OSX, this will prefer the Framework version (if found) over others.
287+# People will have to manually change the cache values of
288+# SDL_LIBRARY to override this selection or set the CMake environment
289+# CMAKE_INCLUDE_PATH to modify the search paths.
290+#
291+# Note that the header path has changed from SDL/SDL.h to just SDL.h
292+# This needed to change because "proper" SDL convention
293+# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
294+# reasons because not all systems place things in SDL/ (see FreeBSD).
295+
296+#=============================================================================
297+# Copyright 2003-2009 Kitware, Inc.
298+#
299+# Distributed under the OSI-approved BSD License (the "License");
300+# see accompanying file Copyright.txt for details.
301+#
302+# This software is distributed WITHOUT ANY WARRANTY; without even the
303+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
304+# See the License for more information.
305+#=============================================================================
306+# (To distributed this file outside of CMake, substitute the full
307+# License text for the above reference.)
308+
309+FIND_PATH(SDL2_INCLUDE_DIR SDL.h
310+ HINTS
311+ $ENV{SDL2DIR}
312+ PATH_SUFFIXES include/SDL2 include
313+ PATHS
314+ ~/Library/Frameworks
315+ /Library/Frameworks
316+ /usr/local/include/SDL2
317+ /sw # Fink
318+ /opt/local # DarwinPorts
319+ /opt/csw # Blastwave
320+ /opt
321+ C:/MinGW #Win32
322+)
323+MESSAGE("SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIR}")
324+
325+FIND_LIBRARY(SDL2_LIBRARY_TEMP
326+ NAMES SDL2
327+ HINTS
328+ $ENV{SDL2DIR}
329+ PATH_SUFFIXES lib64 lib
330+ PATHS
331+ /sw
332+ /opt/local
333+ /opt/csw
334+ /opt
335+ C:/MinGW
336+)
337+
338+#MESSAGE(STATUS "SDL2_LIBRARY_TEMP is ${SDL2_LIBRARY_TEMP}")
339+
340+IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
341+# Non-OS X framework versions expect you to also dynamically link to
342+# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
343+# seem to provide SDLmain for compatibility even though they don't
344+# necessarily need it.
345+FIND_LIBRARY(SDL2MAIN_LIBRARY
346+ NAMES SDL2main
347+ HINTS
348+ $ENV{SDL2DIR}
349+ PATH_SUFFIXES lib64 lib
350+ PATHS
351+ /sw
352+ /opt/local
353+ /opt/csw
354+ /opt
355+ C:/MinGW
356+)
357+ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
358+
359+MESSAGE(STATUS "SDL2MAIN_LIBRARY is ${SDL2MAIN_LIBRARY}")
360+
361+
362+# SDL may require threads on your system.
363+# The Apple build may not need an explicit flag because one of the
364+# frameworks may already provide it.
365+# But for non-OSX systems, I will use the CMake Threads package.
366+IF(NOT APPLE)
367+ FIND_PACKAGE(Threads)
368+ENDIF(NOT APPLE)
369+
370+# MinGW needs an additional library, mwindows
371+# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
372+# (Actually on second look, I think it only needs one of the m* libraries.)
373+IF(MINGW)
374+ SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
375+ENDIF(MINGW)
376+
377+
378+SET(SDL2_FOUND "NO")
379+IF(SDL2_LIBRARY_TEMP)
380+ # For SDLmain
381+ IF(NOT SDL2_BUILDING_LIBRARY)
382+ IF(SDL2MAIN_LIBRARY)
383+ SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
384+ ENDIF(SDL2MAIN_LIBRARY)
385+ ENDIF(NOT SDL2_BUILDING_LIBRARY)
386+
387+ # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
388+ # CMake doesn't display the -framework Cocoa string in the UI even
389+ # though it actually is there if I modify a pre-used variable.
390+ # I think it has something to do with the CACHE STRING.
391+ # So I use a temporary variable until the end so I can set the
392+ # "real" variable in one-shot.
393+ IF(APPLE)
394+ SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
395+ ENDIF(APPLE)
396+
397+ # For threads, as mentioned Apple doesn't need this.
398+ # In fact, there seems to be a problem if I used the Threads package
399+ # and try using this line, so I'm just skipping it entirely for OS X.
400+ IF(NOT APPLE)
401+ SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
402+ ENDIF(NOT APPLE)
403+
404+ # For MinGW library
405+ IF(MINGW)
406+ SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
407+ ENDIF(MINGW)
408+
409+ # Set the final string here so the GUI reflects the final state.
410+ SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
411+ SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP})
412+
413+ # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
414+ SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
415+ IF(NOT SDL2MAIN_LIBRARY)
416+ IF(WIN32)
417+ MESSAGE(FATAL_ERROR "$Could NOT find SDL2 (missing: SDL2main)")
418+ ENDIF(WIN32)
419+ ENDIF(NOT SDL2MAIN_LIBRARY)
420+
421+ IF(NOT SDL2_LIBRARY)
422+ IF(WIN32)
423+ MESSAGE(FATAL_ERROR "$Could NOT find SDL2 (missing: SDL2)")
424+ ENDIF(WIN32)
425+ ENDIF(NOT SDL2_LIBRARY)
426+
427+ SET(SDL2_FOUND "YES")
428+ENDIF(SDL2_LIBRARY_TEMP)
429+
430+#MESSAGE(STATUS "SDL2_LIBRARY is ${SDL2_LIBRARY}")
431+
432
433=== added file 'cmake/Modules/FindSDL2_gfx.cmake'
434--- cmake/Modules/FindSDL2_gfx.cmake 1970-01-01 00:00:00 +0000
435+++ cmake/Modules/FindSDL2_gfx.cmake 2014-11-02 20:06:40 +0000
436@@ -0,0 +1,60 @@
437+# Locate SDL2_gfx library
438+# This module defines
439+# SDL2GFX_LIBRARY, the name of the library to link against
440+# SDL2GFX_FOUND, if false, do not try to link to SDL2
441+# SDL2GFX_INCLUDE_DIR, where to find SDL2/SDL.h
442+#
443+# $SDLDIR is an environment variable that would
444+# correspond to the ./configure --prefix=$SDL2DIR
445+# used in building SDL2.
446+#
447+# Created by Eric Wing. This was influenced by the FindSDL.cmake
448+# module, but with modifications to recognize OS X frameworks and
449+# additional Unix paths (FreeBSD, etc).
450+
451+FIND_PATH(SDL2GFX_INCLUDE_DIR SDL2_framerate.h
452+ SDL2_gfxPrimitives.h
453+ SDL2_imageFilter.h SDL2_rotozoom.h
454+ HINTS
455+ $ENV{SDL2GFXDIR}
456+ $ENV{SDL2DIR}
457+ PATH_SUFFIXES include SDL2
458+ PATHS
459+ ~/Library/Frameworks
460+ /Library/Frameworks
461+ /usr/local/include/SDL2
462+ /usr/include/SDL2
463+ /usr/local/include
464+ /usr/include
465+ /sw/include/SDL2 # Fink
466+ /sw/include
467+ /opt/local/include/SDL2 # DarwinPorts
468+ /opt/local/include
469+ /opt/csw/include/SDL2 # Blastwave
470+ /opt/csw/include
471+ /opt/include/SDL2
472+ /opt/include
473+)
474+
475+FIND_LIBRARY(SDL2GFX_LIBRARY
476+ NAMES SDL2_gfx
477+ HINTS
478+ $ENV{SDL2GFXDIR}
479+ $ENV{SDL2DIR}
480+ PATH_SUFFIXES lib64 lib
481+ PATHS
482+ ~/Library/Frameworks
483+ /Library/Frameworks
484+ /usr/local
485+ /usr
486+ /sw
487+ /opt/local
488+ /opt/csw
489+ /opt
490+)
491+
492+SET(SDL2GFX_FOUND "NO")
493+IF(SDL2GFX_LIBRARY AND SDL2GFX_INCLUDE_DIR)
494+ SET(SDL2GFX_FOUND "YES")
495+ENDIF(SDL2GFX_LIBRARY AND SDL2GFX_INCLUDE_DIR)
496+
497
498=== added file 'cmake/Modules/FindSDL2_image.cmake'
499--- cmake/Modules/FindSDL2_image.cmake 1970-01-01 00:00:00 +0000
500+++ cmake/Modules/FindSDL2_image.cmake 2014-11-02 20:06:40 +0000
501@@ -0,0 +1,88 @@
502+# - Locate SDL2_image library
503+# This module defines:
504+# SDL2_IMAGE_LIBRARIES, the name of the library to link against
505+# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
506+# SDL2_IMAGE_FOUND, if false, do not try to link against
507+# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image
508+#
509+# For backward compatiblity the following variables are also set:
510+# SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
511+# SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
512+# SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
513+#
514+# $SDL2DIR is an environment variable that would
515+# correspond to the ./configure --prefix=$SDL2DIR
516+# used in building SDL2.
517+#
518+# Created by Eric Wing. This was influenced by the FindSDL.cmake
519+# module, but with modifications to recognize OS X frameworks and
520+# additional Unix paths (FreeBSD, etc).
521+
522+#=============================================================================
523+# Copyright 2005-2009 Kitware, Inc.
524+# Copyright 2012 Benjamin Eikel
525+#
526+# Distributed under the OSI-approved BSD License (the "License");
527+# see accompanying file Copyright.txt for details.
528+#
529+# This software is distributed WITHOUT ANY WARRANTY; without even the
530+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
531+# See the License for more information.
532+#=============================================================================
533+# (To distribute this file outside of CMake, substitute the full
534+# License text for the above reference.)
535+
536+if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
537+ set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
538+entry initialized from old variable name")
539+endif()
540+find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
541+ HINTS
542+ ENV SDL2IMAGEDIR
543+ ENV SDL2DIR
544+ PATH_SUFFIXES include/SDL2 include
545+)
546+
547+if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
548+ set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
549+initialized from old variable name")
550+endif()
551+find_library(SDL2_IMAGE_LIBRARY
552+ NAMES SDL2_image
553+ HINTS
554+ ENV SDL2IMAGEDIR
555+ ENV SDL2DIR
556+ PATH_SUFFIXES lib
557+)
558+
559+if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
560+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
561+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
562+ file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
563+ string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MAJOR "${SDL_IMAGE_VERSION_MAJOR_LINE}")
564+ string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_MINOR "${SDL_IMAGE_VERSION_MINOR_LINE}")
565+ string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_IMAGE_VERSION_PATCH "${SDL_IMAGE_VERSION_PATCH_LINE}")
566+ set(SDL_IMAGE_VERSION_STRING ${SDL_IMAGE_VERSION_MAJOR}.${SDL_IMAGE_VERSION_MINOR}.${SDL_IMAGE_VERSION_PATCH})
567+ unset(SDL_IMAGE_VERSION_MAJOR_LINE)
568+ unset(SDL_IMAGE_VERSION_MINOR_LINE)
569+ unset(SDL_IMAGE_VERSION_PATCH_LINE)
570+ unset(SDL_IMAGE_VERSION_MAJOR)
571+ unset(SDL_IMAGE_VERSION_MINOR)
572+ unset(SDL_IMAGE_VERSION_PATCH)
573+endif()
574+
575+set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
576+set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
577+
578+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
579+
580+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
581+ REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
582+ VERSION_VAR SDL2_IMAGE_VERSION_STRING)
583+
584+# for backward compatiblity
585+set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
586+set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
587+set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
588+
589+mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
590
591=== added file 'cmake/Modules/FindSDL2_mixer.cmake'
592--- cmake/Modules/FindSDL2_mixer.cmake 1970-01-01 00:00:00 +0000
593+++ cmake/Modules/FindSDL2_mixer.cmake 2014-11-02 20:06:40 +0000
594@@ -0,0 +1,88 @@
595+# - Locate SDL2_mixer library
596+# This module defines:
597+# SDL2_MIXER_LIBRARIES, the name of the library to link against
598+# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
599+# SDL2_MIXER_FOUND, if false, do not try to link against
600+# SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL_mixer
601+#
602+# For backward compatiblity the following variables are also set:
603+# SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
604+# SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
605+# SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
606+#
607+# $SDL2DIR is an environment variable that would
608+# correspond to the ./configure --prefix=$SDL2DIR
609+# used in building SDL2.
610+#
611+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
612+# module, but with modifications to recognize OS X frameworks and
613+# additional Unix paths (FreeBSD, etc).
614+
615+#=============================================================================
616+# Copyright 2005-2009 Kitware, Inc.
617+# Copyright 2012 Benjamin Eikel
618+#
619+# Distributed under the OSI-approved BSD License (the "License");
620+# see accompanying file Copyright.txt for details.
621+#
622+# This software is distributed WITHOUT ANY WARRANTY; without even the
623+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
624+# See the License for more information.
625+#=============================================================================
626+# (To distribute this file outside of CMake, substitute the full
627+# License text for the above reference.)
628+
629+if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
630+ set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
631+entry initialized from old variable name")
632+endif()
633+find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
634+ HINTS
635+ ENV SDL2MIXERDIR
636+ ENV SDL2DIR
637+ PATH_SUFFIXES include/SDL2 include
638+)
639+
640+if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
641+ set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
642+initialized from old variable name")
643+endif()
644+find_library(SDL2_MIXER_LIBRARY
645+ NAMES SDL2_mixer
646+ HINTS
647+ ENV SDL2MIXERDIR
648+ ENV SDL2DIR
649+ PATH_SUFFIXES lib
650+)
651+
652+if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
653+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
654+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
655+ file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
656+ string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}")
657+ string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}")
658+ string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}")
659+ set(SDL2_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH})
660+ unset(SDL_MIXER_VERSION_MAJOR_LINE)
661+ unset(SDL_MIXER_VERSION_MINOR_LINE)
662+ unset(SDL_MIXER_VERSION_PATCH_LINE)
663+ unset(SDL_MIXER_VERSION_MAJOR)
664+ unset(SDL_MIXER_VERSION_MINOR)
665+ unset(SDL_MIXER_VERSION_PATCH)
666+endif()
667+
668+set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
669+set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
670+
671+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
672+
673+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
674+ REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
675+ VERSION_VAR SDL2_MIXER_VERSION_STRING)
676+
677+# for backward compatiblity
678+set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
679+set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
680+set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
681+
682+mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
683
684=== added file 'cmake/Modules/FindSDL2_net.cmake'
685--- cmake/Modules/FindSDL2_net.cmake 1970-01-01 00:00:00 +0000
686+++ cmake/Modules/FindSDL2_net.cmake 2014-11-02 20:06:40 +0000
687@@ -0,0 +1,88 @@
688+# - Locate SDL2_net library
689+# This module defines:
690+# SDL2_NET_LIBRARIES, the name of the library to link against
691+# SDL2_NET_INCLUDE_DIRS, where to find the headers
692+# SDL2_NET_FOUND, if false, do not try to link against
693+# SDL2_NET_VERSION_STRING - human-readable string containing the version of SDL2_net
694+#
695+# For backward compatiblity the following variables are also set:
696+# SDL2NET_LIBRARY (same value as SDL2_NET_LIBRARIES)
697+# SDL2NET_INCLUDE_DIR (same value as SDL2_NET_INCLUDE_DIRS)
698+# SDL2NET_FOUND (same value as SDL2_NET_FOUND)
699+#
700+# $SDL2DIR is an environment variable that would
701+# correspond to the ./configure --prefix=$SDL2DIR
702+# used in building SDL2.
703+#
704+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
705+# module, but with modifications to recognize OS X frameworks and
706+# additional Unix paths (FreeBSD, etc).
707+
708+#=============================================================================
709+# Copyright 2005-2009 Kitware, Inc.
710+# Copyright 2012 Benjamin Eikel
711+#
712+# Distributed under the OSI-approved BSD License (the "License");
713+# see accompanying file Copyright.txt for details.
714+#
715+# This software is distributed WITHOUT ANY WARRANTY; without even the
716+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
717+# See the License for more information.
718+#=============================================================================
719+# (To distribute this file outside of CMake, substitute the full
720+# License text for the above reference.)
721+
722+if(NOT SDL2_NET_INCLUDE_DIR AND SDL2NET_INCLUDE_DIR)
723+ set(SDL2_NET_INCLUDE_DIR ${SDL2NET_INCLUDE_DIR} CACHE PATH "directory cache
724+entry initialized from old variable name")
725+endif()
726+find_path(SDL2_NET_INCLUDE_DIR SDL_net.h
727+ HINTS
728+ ENV SDL2NETDIR
729+ ENV SDL2DIR
730+ PATH_SUFFIXES include/SDL2 include
731+)
732+
733+if(NOT SDL2_NET_LIBRARY AND SDL2NET_LIBRARY)
734+ set(SDL2_NET_LIBRARY ${SDL2NET_LIBRARY} CACHE FILEPATH "file cache entry
735+initialized from old variable name")
736+endif()
737+find_library(SDL2_NET_LIBRARY
738+ NAMES SDL2_net
739+ HINTS
740+ ENV SDL2NETDIR
741+ ENV SDL2DIR
742+ PATH_SUFFIXES lib
743+)
744+
745+if(SDL2_NET_INCLUDE_DIR AND EXISTS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h")
746+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+[0-9]+$")
747+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+[0-9]+$")
748+ file(STRINGS "${SDL2_NET_INCLUDE_DIR}/SDL_net.h" SDL_NET_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+[0-9]+$")
749+ string(REGEX REPLACE "^#define[ \t]+SDL_NET_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MAJOR "${SDL_NET_VERSION_MAJOR_LINE}")
750+ string(REGEX REPLACE "^#define[ \t]+SDL_NET_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_MINOR "${SDL_NET_VERSION_MINOR_LINE}")
751+ string(REGEX REPLACE "^#define[ \t]+SDL_NET_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_NET_VERSION_PATCH "${SDL_NET_VERSION_PATCH_LINE}")
752+ set(SDL2_NET_VERSION_STRING ${SDL_NET_VERSION_MAJOR}.${SDL_NET_VERSION_MINOR}.${SDL_NET_VERSION_PATCH})
753+ unset(SDL_NET_VERSION_MAJOR_LINE)
754+ unset(SDL_NET_VERSION_MINOR_LINE)
755+ unset(SDL_NET_VERSION_PATCH_LINE)
756+ unset(SDL_NET_VERSION_MAJOR)
757+ unset(SDL_NET_VERSION_MINOR)
758+ unset(SDL_NET_VERSION_PATCH)
759+endif()
760+
761+set(SDL2_NET_LIBRARIES ${SDL2_NET_LIBRARY})
762+set(SDL2_NET_INCLUDE_DIRS ${SDL2_NET_INCLUDE_DIR})
763+
764+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
765+
766+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_net
767+ REQUIRED_VARS SDL2_NET_LIBRARIES SDL2_NET_INCLUDE_DIRS
768+ VERSION_VAR SDL2_NET_VERSION_STRING)
769+
770+# for backward compatiblity
771+set(SDL2NET_LIBRARY ${SDL2_NET_LIBRARIES})
772+set(SDL2NET_INCLUDE_DIR ${SDL2_NET_INCLUDE_DIRS})
773+set(SDL2NET_FOUND ${SDL2_NET_FOUND})
774+
775+mark_as_advanced(SDL2_NET_LIBRARY SDL2_NET_INCLUDE_DIR)
776
777=== added file 'cmake/Modules/FindSDL2_ttf.cmake'
778--- cmake/Modules/FindSDL2_ttf.cmake 1970-01-01 00:00:00 +0000
779+++ cmake/Modules/FindSDL2_ttf.cmake 2014-11-02 20:06:40 +0000
780@@ -0,0 +1,88 @@
781+# - Locate SDL2_ttf library
782+# This module defines:
783+# SDL2_TTF_LIBRARIES, the name of the library to link against
784+# SDL2_TTF_INCLUDE_DIRS, where to find the headers
785+# SDL2_TTF_FOUND, if false, do not try to link against
786+# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
787+#
788+# For backward compatiblity the following variables are also set:
789+# SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
790+# SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
791+# SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
792+#
793+# $SDL2DIR is an environment variable that would
794+# correspond to the ./configure --prefix=$SDL2DIR
795+# used in building SDL2.
796+#
797+# Created by Eric Wing. This was influenced by the FindSDL2.cmake
798+# module, but with modifications to recognize OS X frameworks and
799+# additional Unix paths (FreeBSD, etc).
800+
801+#=============================================================================
802+# Copyright 2005-2009 Kitware, Inc.
803+# Copyright 2012 Benjamin Eikel
804+#
805+# Distributed under the OSI-approved BSD License (the "License");
806+# see accompanying file Copyright.txt for details.
807+#
808+# This software is distributed WITHOUT ANY WARRANTY; without even the
809+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
810+# See the License for more information.
811+#=============================================================================
812+# (To distribute this file outside of CMake, substitute the full
813+# License text for the above reference.)
814+
815+if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
816+ set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
817+entry initialized from old variable name")
818+endif()
819+find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
820+ HINTS
821+ ENV SDL2TTFDIR
822+ ENV SDL2DIR
823+ PATH_SUFFIXES include/SDL2 include
824+)
825+
826+if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
827+ set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
828+initialized from old variable name")
829+endif()
830+find_library(SDL2_TTF_LIBRARY
831+ NAMES SDL2_ttf
832+ HINTS
833+ ENV SDL2TTFDIR
834+ ENV SDL2DIR
835+ PATH_SUFFIXES lib
836+)
837+
838+if(SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h")
839+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$")
840+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$")
841+ file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$")
842+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}")
843+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}")
844+ string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}")
845+ set(SDL2_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH})
846+ unset(SDL_TTF_VERSION_MAJOR_LINE)
847+ unset(SDL_TTF_VERSION_MINOR_LINE)
848+ unset(SDL_TTF_VERSION_PATCH_LINE)
849+ unset(SDL_TTF_VERSION_MAJOR)
850+ unset(SDL_TTF_VERSION_MINOR)
851+ unset(SDL_TTF_VERSION_PATCH)
852+endif()
853+
854+set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
855+set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
856+
857+# include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
858+
859+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
860+ REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
861+ VERSION_VAR SDL2_TTF_VERSION_STRING)
862+
863+# for backward compatiblity
864+set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
865+set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
866+set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
867+
868+mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
869
870=== removed file 'cmake/Modules/FindSDL_gfx.cmake'
871--- cmake/Modules/FindSDL_gfx.cmake 2013-01-24 11:42:08 +0000
872+++ cmake/Modules/FindSDL_gfx.cmake 1970-01-01 00:00:00 +0000
873@@ -1,64 +0,0 @@
874-# Locate SDL_gfx library
875-# This module defines
876-# SDLGFX_LIBRARY, the name of the library to link against
877-# SDLGFX_FOUND, if false, do not try to link to SDL
878-# SDLGFX_INCLUDE_DIR, where to find SDL/SDL.h
879-#
880-# $SDLDIR is an environment variable that would
881-# correspond to the ./configure --prefix=$SDLDIR
882-# used in building SDL.
883-#
884-# Created by Eric Wing. This was influenced by the FindSDL.cmake
885-# module, but with modifications to recognize OS X frameworks and
886-# additional Unix paths (FreeBSD, etc).
887-
888-FIND_PATH(SDLGFX_INCLUDE_DIR SDL_framerate.h SDL_gfxBlitFunc.h
889- SDL_gfxPrimitives.h SDL_gfxPrimitives_font.h
890- SDL_imageFilter.h SDL_rotozoom.h
891- HINTS
892- $ENV{SDLGFXDIR}
893- $ENV{SDLDIR}
894- PATH_SUFFIXES include SDL
895- PATHS
896- ~/Library/Frameworks
897- /Library/Frameworks
898- /usr/local/include/SDL
899- /usr/include/SDL
900- /usr/local/include/SDL12
901- /usr/local/include/SDL11 # FreeBSD ports
902- /usr/include/SDL12
903- /usr/include/SDL11
904- /usr/local/include
905- /usr/include
906- /sw/include/SDL # Fink
907- /sw/include
908- /opt/local/include/SDL # DarwinPorts
909- /opt/local/include
910- /opt/csw/include/SDL # Blastwave
911- /opt/csw/include
912- /opt/include/SDL
913- /opt/include
914-)
915-
916-FIND_LIBRARY(SDLGFX_LIBRARY
917- NAMES SDL_gfx
918- HINTS
919- $ENV{SDLGFXDIR}
920- $ENV{SDLDIR}
921- PATH_SUFFIXES lib64 lib
922- PATHS
923- ~/Library/Frameworks
924- /Library/Frameworks
925- /usr/local
926- /usr
927- /sw
928- /opt/local
929- /opt/csw
930- /opt
931-)
932-
933-SET(SDLGFX_FOUND "NO")
934-IF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR)
935- SET(SDLGFX_FOUND "YES")
936-ENDIF(SDLGFX_LIBRARY AND SDLGFX_INCLUDE_DIR)
937-
938
939=== modified file 'cmake/WlFunctions.cmake'
940--- cmake/WlFunctions.cmake 2014-07-17 14:34:32 +0000
941+++ cmake/WlFunctions.cmake 2014-11-02 20:06:40 +0000
942@@ -9,12 +9,12 @@
943 USES_INTL
944 USES_OPENGL
945 USES_PNG
946- USES_SDL
947- USES_SDL_GFX
948- USES_SDL_IMAGE
949- USES_SDL_MIXER
950- USES_SDL_NET
951- USES_SDL_TTF
952+ USES_SDL2
953+ USES_SDL2_GFX
954+ USES_SDL2_IMAGE
955+ USES_SDL2_MIXER
956+ USES_SDL2_NET
957+ USES_SDL2_TTF
958 USES_ZLIB
959 )
960 set(ONE_VALUE_ARG )
961@@ -98,34 +98,34 @@
962 target_link_libraries(${NAME} ${PNG_LIBRARY})
963 endif()
964
965- if(ARG_USES_SDL)
966- wl_include_system_directories(${NAME} ${SDL_INCLUDE_DIR})
967- target_link_libraries(${NAME} ${SDL_LIBRARY})
968- endif()
969-
970- if(ARG_USES_SDL_MIXER)
971- wl_include_system_directories(${NAME} ${SDLMIXER_INCLUDE_DIR})
972- target_link_libraries(${NAME} ${SDLMIXER_LIBRARY})
973- endif()
974-
975- if(ARG_USES_SDL_NET)
976- wl_include_system_directories(${NAME} ${SDLNET_INCLUDE_DIR})
977- target_link_libraries(${NAME} ${SDLNET_LIBRARY})
978- endif()
979-
980- if(ARG_USES_SDL_IMAGE)
981- wl_include_system_directories(${NAME} ${SDLIMAGE_INCLUDE_DIR})
982- target_link_libraries(${NAME} ${SDLIMAGE_LIBRARY})
983- endif()
984-
985- if(ARG_USES_SDL_GFX)
986- wl_include_system_directories(${NAME} ${SDLGFX_INCLUDE_DIR})
987- target_link_libraries(${NAME} ${SDLGFX_LIBRARY})
988- endif()
989-
990- if(ARG_USES_SDL_TTF)
991- wl_include_system_directories(${NAME} ${SDLTTF_INCLUDE_DIR})
992- target_link_libraries(${NAME} ${SDLTTF_LIBRARY})
993+ if(ARG_USES_SDL2)
994+ wl_include_system_directories(${NAME} ${SDL2_INCLUDE_DIR})
995+ target_link_libraries(${NAME} ${SDL2_LIBRARY})
996+ endif()
997+
998+ if(ARG_USES_SDL2_MIXER)
999+ wl_include_system_directories(${NAME} ${SDL2MIXER_INCLUDE_DIR})
1000+ target_link_libraries(${NAME} ${SDL2MIXER_LIBRARY})
1001+ endif()
1002+
1003+ if(ARG_USES_SDL2_NET)
1004+ wl_include_system_directories(${NAME} ${SDL2NET_INCLUDE_DIR})
1005+ target_link_libraries(${NAME} ${SDL2NET_LIBRARY})
1006+ endif()
1007+
1008+ if(ARG_USES_SDL2_IMAGE)
1009+ wl_include_system_directories(${NAME} ${SDL2IMAGE_INCLUDE_DIR})
1010+ target_link_libraries(${NAME} ${SDL2IMAGE_LIBRARY})
1011+ endif()
1012+
1013+ if(ARG_USES_SDL2_GFX)
1014+ wl_include_system_directories(${NAME} ${SDL2GFX_INCLUDE_DIR})
1015+ target_link_libraries(${NAME} ${SDL2GFX_LIBRARY})
1016+ endif()
1017+
1018+ if(ARG_USES_SDL2_TTF)
1019+ wl_include_system_directories(${NAME} ${SDL2TTF_INCLUDE_DIR})
1020+ target_link_libraries(${NAME} ${SDL2TTF_LIBRARY})
1021 endif()
1022
1023 if (ARG_USES_INTL)
1024@@ -176,10 +176,10 @@
1025 endif()
1026 target_link_libraries(${NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
1027
1028- # Tests need to link with SDL library without main.
1029- set(SDL_LIBRARY_TEMP ${SDL_LIBRARY})
1030- list(REMOVE_ITEM SDL_LIBRARY_TEMP ${SDLMAIN_LIBRARY})
1031- target_link_libraries(${NAME} ${SDL_LIBRARY_TEMP})
1032+ # Tests need to link with SDL2 library without main.
1033+ set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY})
1034+ list(REMOVE_ITEM SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY})
1035+ target_link_libraries(${NAME} ${SDL2_LIBRARY_TEMP})
1036
1037 _common_compile_tasks()
1038
1039
1040=== modified file 'cmake/codecheck/rules/correct_include_order'
1041--- cmake/codecheck/rules/correct_include_order 2013-07-26 20:19:36 +0000
1042+++ cmake/codecheck/rules/correct_include_order 2014-11-02 20:06:40 +0000
1043@@ -70,7 +70,7 @@
1044 if blocks and blocks[0][0][1] == "<": # library includes.
1045 for lineno, delimiter, header in blocks[0]:
1046 if '.h' not in header or delimiter != "<":
1047- errors.append((fn, lineno, "This include block must only contain library headers (e.g. SDL)."))
1048+ errors.append((fn, lineno, "This include block must only contain library headers (e.g. SDL2)."))
1049 return errors
1050 blocks.pop(0)
1051
1052@@ -95,7 +95,7 @@
1053 allowed = [
1054 """#include <memory>
1055
1056-#include <SDL.h>
1057+#include <SDL2.h>
1058 """,
1059
1060 """
1061@@ -120,7 +120,7 @@
1062 ###################
1063 forbidden = [
1064 """
1065-#include <SDL.h>
1066+#include <SDL2.h>
1067
1068 #include <memory>
1069 """,
1070@@ -133,7 +133,7 @@
1071
1072 """
1073 #include <memory>
1074-#include <SDL.h>
1075+#include <SDL2.h>
1076 """
1077
1078 ]
1079
1080=== modified file 'src/CMakeLists.txt'
1081--- src/CMakeLists.txt 2014-09-16 09:54:41 +0000
1082+++ src/CMakeLists.txt 2014-11-02 20:06:40 +0000
1083@@ -43,7 +43,7 @@
1084 SRCS
1085 main.cc
1086 ${WIN32_ICON_O}
1087- USES_SDL
1088+ USES_SDL2
1089 DEPENDS
1090 base_log
1091 base_exceptions
1092@@ -54,7 +54,7 @@
1093 wl_binary(widelands
1094 SRCS
1095 main.cc
1096- USES_SDL
1097+ USES_SDL2
1098 DEPENDS
1099 base_log
1100 base_exceptions
1101@@ -92,7 +92,7 @@
1102 wlapplication.h
1103 wlapplication_messages.cc
1104 wlapplication_messages.h
1105- USES_SDL
1106+ USES_SDL2
1107 DEPENDS
1108 base_exceptions
1109 base_geometry
1110@@ -122,7 +122,7 @@
1111 SRCS
1112 helper.cc
1113 helper.h
1114- USES_SDL
1115+ USES_SDL2
1116 DEPENDS
1117 base_exceptions
1118 )
1119
1120=== modified file 'src/base/CMakeLists.txt'
1121--- src/base/CMakeLists.txt 2014-08-28 06:58:29 +0000
1122+++ src/base/CMakeLists.txt 2014-11-02 20:06:40 +0000
1123@@ -58,7 +58,7 @@
1124 SRCS
1125 scoped_timer.h
1126 scoped_timer.cc
1127- USES_SDL
1128+ USES_SDL2
1129 DEPENDS
1130 base_log
1131 base_macros
1132
1133=== modified file 'src/editor/CMakeLists.txt'
1134--- src/editor/CMakeLists.txt 2014-07-05 13:14:42 +0000
1135+++ src/editor/CMakeLists.txt 2014-11-02 20:06:40 +0000
1136@@ -83,7 +83,7 @@
1137 ui_menus/editor_tool_set_terrain_options_menu.h
1138 ui_menus/editor_toolsize_menu.cc
1139 ui_menus/editor_toolsize_menu.h
1140- USES_SDL
1141+ USES_SDL2
1142 DEPENDS
1143 base_exceptions
1144 base_i18n
1145
1146=== modified file 'src/editor/editorinteractive.cc'
1147--- src/editor/editorinteractive.cc 2014-09-19 12:54:54 +0000
1148+++ src/editor/editorinteractive.cc 2014-11-02 20:06:40 +0000
1149@@ -23,7 +23,7 @@
1150 #include <string>
1151 #include <vector>
1152
1153-#include <SDL_keysym.h>
1154+#include <SDL_keycode.h>
1155 #include <boost/format.hpp>
1156
1157 #include "base/i18n.h"
1158@@ -344,7 +344,7 @@
1159 }
1160
1161
1162-bool EditorInteractive::handle_key(bool const down, SDL_keysym const code) {
1163+bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) {
1164 bool handled = InteractiveBase::handle_key(down, code);
1165
1166 if (down) {
1167@@ -393,16 +393,16 @@
1168 handled = true;
1169 break;
1170
1171- case SDLK_LSHIFT:
1172- case SDLK_RSHIFT:
1173+ case SDL_SCANCODE_LSHIFT:
1174+ case SDL_SCANCODE_RSHIFT:
1175 if (tools.use_tool == EditorTool::First)
1176 select_tool(tools.current(), EditorTool::Second);
1177 handled = true;
1178 break;
1179
1180- case SDLK_LALT:
1181- case SDLK_RALT:
1182- case SDLK_MODE:
1183+ case SDL_SCANCODE_LALT:
1184+ case SDL_SCANCODE_RALT:
1185+ case SDL_SCANCODE_MODE:
1186 if (tools.use_tool == EditorTool::First)
1187 select_tool(tools.current(), EditorTool::Third);
1188 handled = true;
1189@@ -481,11 +481,11 @@
1190 } else {
1191 // key up events
1192 switch (code.sym) {
1193- case SDLK_LSHIFT:
1194- case SDLK_RSHIFT:
1195- case SDLK_LALT:
1196- case SDLK_RALT:
1197- case SDLK_MODE:
1198+ case SDL_SCANCODE_LSHIFT:
1199+ case SDL_SCANCODE_RSHIFT:
1200+ case SDL_SCANCODE_LALT:
1201+ case SDL_SCANCODE_RALT:
1202+ case SDL_SCANCODE_MODE:
1203 if (tools.use_tool != EditorTool::First)
1204 select_tool(tools.current(), EditorTool::First);
1205 handled = true;
1206
1207=== modified file 'src/editor/editorinteractive.h'
1208--- src/editor/editorinteractive.h 2014-09-14 11:31:58 +0000
1209+++ src/editor/editorinteractive.h 2014-11-02 20:06:40 +0000
1210@@ -66,7 +66,7 @@
1211 void set_sel_radius_and_update_menu(uint32_t);
1212
1213 // Handle UI elements.
1214- bool handle_key(bool down, SDL_keysym) override;
1215+ bool handle_key(bool down, SDL_Keysym) override;
1216 bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
1217 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
1218
1219
1220=== modified file 'src/editor/ui_menus/categorized_item_selection_menu.h'
1221--- src/editor/ui_menus/categorized_item_selection_menu.h 2014-09-10 14:48:40 +0000
1222+++ src/editor/ui_menus/categorized_item_selection_menu.h 2014-11-02 20:06:40 +0000
1223@@ -144,7 +144,7 @@
1224 // TODO(unknown): This code is erroneous. It checks the current key state. What it
1225 // needs is the key state at the time the mouse was clicked. See the
1226 // usage comment for get_key_state.
1227- const bool multiselect = get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
1228+ const bool multiselect = get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL);
1229 if (!t && (!multiselect || tool_->get_nr_enabled() == 1))
1230 checkboxes_[n]->set_state(true);
1231 else {
1232
1233=== modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
1234--- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-10-28 08:16:53 +0000
1235+++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-11-02 20:06:40 +0000
1236@@ -65,6 +65,7 @@
1237 get_inner_w() / 2 - spacing, get_inner_h() - spacing - offsy - 40);
1238 m_ls->selected.connect(boost::bind(&MainMenuLoadMap::selected, this, _1));
1239 m_ls->double_clicked.connect(boost::bind(&MainMenuLoadMap::double_clicked, this, _1));
1240+ m_ls->focus();
1241
1242 posx = get_inner_w() / 2 + spacing;
1243 new UI::Textarea
1244
1245=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
1246--- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-10-28 08:16:53 +0000
1247+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-11-02 20:06:40 +0000
1248@@ -67,6 +67,7 @@
1249 get_inner_w() / 2 - spacing, get_inner_h() - spacing - offsy - 60);
1250 m_ls->clicked.connect(boost::bind(&MainMenuSaveMap::clicked_item, this, _1));
1251 m_ls->double_clicked.connect(boost::bind(&MainMenuSaveMap::double_clicked_item, this, _1));
1252+ m_ls->focus();
1253 m_editbox =
1254 new UI::EditBox
1255 (this,
1256
1257=== modified file 'src/editor/ui_menus/editor_tool_place_bob_options_menu.cc'
1258--- src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-09-10 14:08:25 +0000
1259+++ src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-11-02 20:06:40 +0000
1260@@ -19,7 +19,7 @@
1261
1262 #include "editor/ui_menus/editor_tool_place_bob_options_menu.h"
1263
1264-#include <SDL_keysym.h>
1265+#include <SDL_keycode.h>
1266
1267 #include "base/i18n.h"
1268 #include "base/macros.h"
1269@@ -124,7 +124,7 @@
1270 // TODO(unknown): needs is the key state at the time the mouse was clicked. See the
1271 // TODO(unknown): usage comment for get_key_state.
1272 const bool multiselect =
1273- get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
1274+ get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL);
1275 if (!t && (!multiselect || m_pit.get_nr_enabled() == 1)) {
1276 m_checkboxes[n]->set_state(true);
1277 return;
1278
1279=== modified file 'src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc'
1280--- src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2014-09-10 14:08:25 +0000
1281+++ src/editor/ui_menus/editor_tool_place_immovable_options_menu.cc 2014-11-02 20:06:40 +0000
1282@@ -19,7 +19,7 @@
1283
1284 #include "editor/ui_menus/editor_tool_place_immovable_options_menu.h"
1285
1286-#include <SDL_keysym.h>
1287+#include <SDL_keycode.h>
1288
1289 #include "base/i18n.h"
1290 #include "editor/editorinteractive.h"
1291
1292=== modified file 'src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc'
1293--- src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-10-27 10:14:10 +0000
1294+++ src/editor/ui_menus/editor_tool_set_terrain_options_menu.cc 2014-11-02 20:06:40 +0000
1295@@ -21,7 +21,7 @@
1296
1297 #include <memory>
1298
1299-#include <SDL_keysym.h>
1300+#include <SDL_keycode.h>
1301 #include <boost/format.hpp>
1302
1303 #include "base/i18n.h"
1304
1305=== modified file 'src/graphic/CMakeLists.txt'
1306--- src/graphic/CMakeLists.txt 2014-11-01 19:51:53 +0000
1307+++ src/graphic/CMakeLists.txt 2014-11-02 20:06:40 +0000
1308@@ -4,7 +4,7 @@
1309 SRCS
1310 color.h
1311 color.cc
1312- USES_SDL
1313+ USES_SDL2
1314 )
1315
1316 wl_library(graphic_image_io
1317@@ -12,8 +12,8 @@
1318 image_io.h
1319 image_io.cc
1320 USES_PNG
1321- USES_SDL
1322- USES_SDL_IMAGE
1323+ USES_SDL2
1324+ USES_SDL2_IMAGE
1325 DEPENDS
1326 base_exceptions
1327 graphic_surface
1328@@ -27,8 +27,8 @@
1329 image.h
1330 image_cache.cc
1331 image_cache.h
1332- USES_SDL
1333- USES_SDL_IMAGE
1334+ USES_SDL2
1335+ USES_SDL2_IMAGE
1336 DEPENDS
1337 base_log
1338 base_macros
1339@@ -56,7 +56,7 @@
1340 surface_cache.cc
1341 surface_cache.h
1342 USES_OPENGL
1343- USES_SDL
1344+ USES_SDL2
1345 DEPENDS
1346 base_macros
1347 base_exceptions
1348@@ -117,10 +117,10 @@
1349 wordwrap.cc
1350 wordwrap.h
1351 USES_OPENGL
1352- USES_SDL
1353- USES_SDL_GFX
1354- USES_SDL_IMAGE
1355- USES_SDL_TTF
1356+ USES_SDL2
1357+ USES_SDL2_GFX
1358+ USES_SDL2_IMAGE
1359+ USES_SDL2_TTF
1360 DEPENDS
1361 base_deprecated
1362 base_exceptions
1363
1364=== modified file 'src/graphic/font_handler.cc'
1365--- src/graphic/font_handler.cc 2014-09-14 11:31:58 +0000
1366+++ src/graphic/font_handler.cc 2014-11-02 20:06:40 +0000
1367@@ -175,7 +175,7 @@
1368 void FontHandler::Data::render_line(LineCacheEntry & lce)
1369 {
1370 TTF_Font * font = lce.style.font->get_ttf_font();
1371- SDL_Color sdl_fg = {lce.style.fg.r, lce.style.fg.g, lce.style.fg.b, 0};
1372+ SDL_Color sdl_fg = {lce.style.fg.r, lce.style.fg.g, lce.style.fg.b, SDL_ALPHA_OPAQUE};
1373
1374 // Work around an Issue in SDL_TTF that dies when the surface
1375 // has zero width
1376
1377=== modified file 'src/graphic/gl/surface_texture.cc'
1378--- src/graphic/gl/surface_texture.cc 2014-10-11 13:26:59 +0000
1379+++ src/graphic/gl/surface_texture.cc 2014-11-02 20:06:40 +0000
1380@@ -100,7 +100,7 @@
1381 uint8_t bpp = surface->format->BytesPerPixel;
1382
1383 if
1384- (surface->format->palette || (surface->format->colorkey > 0) ||
1385+ (surface->format->palette ||
1386 m_tex_w != static_cast<uint32_t>(surface->w) ||
1387 m_tex_h != static_cast<uint32_t>(surface->h) ||
1388 (bpp != 3 && bpp != 4))
1389@@ -109,8 +109,10 @@
1390 (SDL_SWSURFACE, m_tex_w, m_tex_h,
1391 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
1392 assert(converted);
1393- SDL_SetAlpha(converted, 0, 0);
1394- SDL_SetAlpha(surface, 0, 0);
1395+ SDL_SetSurfaceAlphaMod(converted, SDL_ALPHA_OPAQUE);
1396+ SDL_SetSurfaceBlendMode(converted, SDL_BLENDMODE_NONE);
1397+ SDL_SetSurfaceAlphaMod(surface, SDL_ALPHA_OPAQUE);
1398+ SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
1399 SDL_BlitSurface(surface, nullptr, converted, nullptr);
1400 SDL_FreeSurface(surface);
1401 surface = converted;
1402
1403=== modified file 'src/graphic/graphic.cc'
1404--- src/graphic/graphic.cc 2014-10-11 13:26:59 +0000
1405+++ src/graphic/graphic.cc 2014-11-02 20:06:40 +0000
1406@@ -54,9 +54,8 @@
1407 Graphic * g_gr;
1408 bool g_opengl;
1409
1410-#define FALLBACK_GRAPHICS_WIDTH 800
1411-#define FALLBACK_GRAPHICS_HEIGHT 600
1412-#define FALLBACK_GRAPHICS_DEPTH 32
1413+constexpr int kFallbackGraphicsWidth = 800;
1414+constexpr int kFallbackGraphicsHeight = 600;
1415
1416 namespace {
1417
1418@@ -71,9 +70,8 @@
1419 */
1420 Graphic::Graphic()
1421 :
1422- m_fallback_settings_in_effect (false),
1423- m_nr_update_rects (0),
1424- m_update_fullscreen(true),
1425+ m_fallback_settings_in_effect(false),
1426+ m_update(true),
1427 surface_cache_(create_surface_cache(TRANSIENT_SURFACE_CACHE_SIZE)),
1428 image_cache_(new ImageCache(surface_cache_.get())),
1429 animation_manager_(new AnimationManager())
1430@@ -85,9 +83,11 @@
1431 #else
1432 const std::string icon_name = "pics/wl-ico-32.png";
1433 #endif
1434- SDL_Surface* s = load_image_as_sdl_surface(icon_name, g_fs);
1435- SDL_WM_SetIcon(s, nullptr);
1436- SDL_FreeSurface(s);
1437+ m_sdlwindow = nullptr;
1438+ m_sdl_screen = nullptr;
1439+ m_sdl_renderer = nullptr;
1440+ m_sdl_texture = nullptr;
1441+ m_glcontext = nullptr;
1442 }
1443
1444 void Graphic::initialize(int32_t w, int32_t h, bool fullscreen, bool opengl) {
1445@@ -96,7 +96,6 @@
1446 // Set video mode using SDL. First collect the flags
1447 int32_t flags = 0;
1448 g_opengl = false;
1449- SDL_Surface * sdlsurface = nullptr;
1450
1451 if (opengl) {
1452 log("Graphics: Trying opengl\n");
1453@@ -105,52 +104,72 @@
1454 // here instead of relying on SDL to give us whatever.
1455
1456 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
1457- flags |= SDL_OPENGL;
1458+ flags |= SDL_WINDOW_OPENGL;
1459 }
1460
1461 if (fullscreen) {
1462- flags |= SDL_FULLSCREEN;
1463+ flags |= SDL_WINDOW_FULLSCREEN;
1464 log("Graphics: Trying FULLSCREEN\n");
1465 }
1466
1467 log("Graphics: Try to set Videomode %ux%u 32 Bit\n", w, h);
1468 // Here we actually set the video mode
1469- sdlsurface = SDL_SetVideoMode(w, h, 32, flags);
1470-
1471+ m_sdlwindow = SDL_CreateWindow("Widelands Window",
1472+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
1473+ if (opengl) {
1474+ // TODO(sirver): this context needs to be created also for fallback settings,
1475+ // otherwise SDL_GetWindowFlags() will return SDL_WINDOW_OPENGL,
1476+ // though if you call any gl function, the system crashes.
1477+ m_glcontext = SDL_GL_CreateContext(m_sdlwindow);
1478+ if (m_glcontext) {
1479+ SDL_GL_MakeCurrent(m_sdlwindow, m_glcontext);
1480+ }
1481+ }
1482 // If we tried opengl and it was not successful try without opengl
1483- if (!sdlsurface && opengl)
1484+ if ((!m_sdlwindow || !m_glcontext) && opengl)
1485 {
1486 log("Graphics: Could not set videomode: %s, trying without opengl\n", SDL_GetError());
1487- flags &= ~SDL_OPENGL;
1488- sdlsurface = SDL_SetVideoMode(w, h, 32, flags);
1489+ flags &= ~SDL_WINDOW_OPENGL;
1490+ m_sdlwindow = SDL_CreateWindow("Widelands Window",
1491+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags);
1492 }
1493
1494- if (!sdlsurface)
1495- {
1496+ if (!m_sdlwindow) {
1497 log
1498 ("Graphics: Could not set videomode: %s, trying minimum graphics settings\n",
1499 SDL_GetError());
1500- flags &= ~SDL_FULLSCREEN;
1501- sdlsurface = SDL_SetVideoMode
1502- (FALLBACK_GRAPHICS_WIDTH, FALLBACK_GRAPHICS_HEIGHT, FALLBACK_GRAPHICS_DEPTH, flags);
1503+ flags &= ~SDL_WINDOW_FULLSCREEN;
1504+ m_sdlwindow = SDL_CreateWindow("Widelands Window",
1505+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
1506+ kFallbackGraphicsWidth, kFallbackGraphicsHeight, flags);
1507 m_fallback_settings_in_effect = true;
1508- if (!sdlsurface)
1509+ if (!m_sdlwindow) {
1510 throw wexception
1511 ("Graphics: could not set video mode: %s", SDL_GetError());
1512+ }
1513 }
1514
1515+#ifndef _WIN32
1516+ const std::string icon_name = "pics/wl-ico-128.png";
1517+#else
1518+ const std::string icon_name = "pics/wl-ico-32.png";
1519+#endif
1520+ SDL_Surface* s = load_image_as_sdl_surface(icon_name, g_fs);
1521+ SDL_SetWindowIcon(m_sdlwindow, s);
1522+ SDL_FreeSurface(s);
1523+
1524 // setting the videomode was successful. Print some information now
1525 log("Graphics: Setting video mode was successful\n");
1526
1527- if (opengl && 0 != (sdlsurface->flags & SDL_GL_DOUBLEBUFFER))
1528+ if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_GL_DOUBLEBUFFER))
1529 log("Graphics: OPENGL DOUBLE BUFFERING ENABLED\n");
1530- if (0 != (sdlsurface->flags & SDL_FULLSCREEN))
1531+ if (0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN))
1532 log("Graphics: FULLSCREEN ENABLED\n");
1533
1534 bool use_arb = true;
1535 const char * extensions = nullptr;
1536
1537- if (0 != (sdlsurface->flags & SDL_OPENGL)) {
1538+ if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_OPENGL)) {
1539 // We have successful opened an opengl screen. Print some information
1540 // about opengl and set the rendering capabilities.
1541 log ("Graphics: OpenGL: OpenGL enabled\n");
1542@@ -160,7 +179,8 @@
1543 glewExperimental = GL_TRUE;
1544 GLenum err = glewInit();
1545 if (err != GLEW_OK) {
1546- log("glewInit returns %i\nYour OpenGL installation must be __very__ broken.\n", err);
1547+ log("glewInit returns %i\nYour OpenGL installation must be __very__ broken. %s\n",
1548+ err, glewGetErrorString(err));
1549 throw wexception("glewInit returns %i: Broken OpenGL installation.", err);
1550 }
1551
1552@@ -175,23 +195,22 @@
1553 ("Graphics: Neither GL_ARB_framebuffer_object or GL_EXT_framebuffer_object supported! "
1554 "Switching off OpenGL!\n"
1555 );
1556- flags &= ~SDL_OPENGL;
1557- m_fallback_settings_in_effect = true;
1558-
1559- // One must never free the screen surface of SDL (using
1560- // SDL_FreeSurface) as it is owned by SDL itself, therefore the next
1561- // call does not leak memory.
1562- sdlsurface = SDL_SetVideoMode
1563- (FALLBACK_GRAPHICS_WIDTH, FALLBACK_GRAPHICS_HEIGHT, FALLBACK_GRAPHICS_DEPTH, flags);
1564- m_fallback_settings_in_effect = true;
1565- if (!sdlsurface)
1566+ flags &= ~SDL_WINDOW_OPENGL;
1567+ m_fallback_settings_in_effect = true;
1568+ SDL_DestroyWindow(m_sdlwindow);
1569+ m_sdlwindow = SDL_CreateWindow("Widelands Window",
1570+ SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
1571+ kFallbackGraphicsWidth, kFallbackGraphicsHeight, flags);
1572+ m_fallback_settings_in_effect = true;
1573+ if (!m_sdlwindow) {
1574 throw wexception("Graphics: could not set video mode: %s", SDL_GetError());
1575+ }
1576 }
1577 }
1578 Surface::display_format_is_now_defined();
1579
1580 // Redoing the check, because fallback settings might mean we no longer use OpenGL.
1581- if (0 != (sdlsurface->flags & SDL_OPENGL)) {
1582+ if (opengl && 0 != (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_OPENGL)) {
1583 // We now really have a working opengl screen...
1584 g_opengl = true;
1585
1586@@ -236,48 +255,26 @@
1587 }
1588
1589 /* Information about the video capabilities. */
1590- const SDL_VideoInfo* info = SDL_GetVideoInfo();
1591- char videodrvused[16];
1592- SDL_VideoDriverName(videodrvused, 16);
1593+ SDL_DisplayMode disp_mode;
1594+ SDL_GetWindowDisplayMode(m_sdlwindow, &disp_mode);
1595+ const char * videodrvused = SDL_GetCurrentVideoDriver();
1596 log
1597 ("**** GRAPHICS REPORT ****\n"
1598 " VIDEO DRIVER %s\n"
1599- " hw surface possible %d\n"
1600- " window manager available %d\n"
1601- " blitz_hw %d\n"
1602- " blitz_hw_CC %d\n"
1603- " blitz_hw_A %d\n"
1604- " blitz_sw %d\n"
1605- " blitz_sw_CC %d\n"
1606- " blitz_sw_A %d\n"
1607- " blitz_fill %d\n"
1608- " video_mem %d\n"
1609- " vfmt %p\n"
1610+ " pixel fmt %u\n"
1611 " size %d %d\n"
1612 "**** END GRAPHICS REPORT ****\n",
1613 videodrvused,
1614- info->hw_available,
1615- info->wm_available,
1616- info->blit_hw,
1617- info->blit_hw_CC,
1618- info->blit_hw_A,
1619- info->blit_sw,
1620- info->blit_sw_CC,
1621- info->blit_sw_A,
1622- info->blit_fill,
1623- info->video_mem,
1624- info->vfmt,
1625- info->current_w, info->current_h);
1626+ disp_mode.format,
1627+ disp_mode.w, disp_mode.h);
1628
1629- log("Graphics: flags: %x\n", sdlsurface->flags);
1630+ log("Graphics: flags: %u\n", SDL_GetWindowFlags(m_sdlwindow));
1631
1632 assert
1633- (sdlsurface->format->BytesPerPixel == 2 ||
1634- sdlsurface->format->BytesPerPixel == 4);
1635+ (SDL_BYTESPERPIXEL(disp_mode.format) == 2 ||
1636+ SDL_BYTESPERPIXEL(disp_mode.format) == 4);
1637
1638- SDL_WM_SetCaption
1639- (("Widelands " + build_id() + '(' + build_type() + ')').c_str(),
1640- "Widelands");
1641+ SDL_SetWindowTitle(m_sdlwindow, ("Widelands " + build_id() + '(' + build_type() + ')').c_str());
1642
1643 if (g_opengl) {
1644 glViewport(0, 0, w, h);
1645@@ -303,7 +300,8 @@
1646 // Clear the screen before running the game.
1647 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
1648 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1649- SDL_GL_SwapBuffers();
1650+ SDL_GL_SetSwapInterval(1);
1651+ SDL_GL_SwapWindow(m_sdlwindow);
1652 glEnable(GL_TEXTURE_2D);
1653
1654 GLSurfaceTexture::initialize(use_arb);
1655@@ -313,12 +311,18 @@
1656 {
1657 screen_.reset(new GLSurfaceScreen(w, h));
1658 }
1659- else
1660- {
1661- screen_.reset(new SDLSurface(sdlsurface, false));
1662+ else {
1663+ m_sdl_renderer = SDL_CreateRenderer(m_sdlwindow, -1, 0);
1664+ uint32_t rmask, gmask, bmask, amask;
1665+ int bpp;
1666+ SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ARGB8888, &bpp, &rmask, &gmask, &bmask, &amask);
1667+ m_sdl_screen = SDL_CreateRGBSurface(0, w, h, bpp, rmask, gmask, bmask, amask);
1668+ m_sdl_texture = SDL_CreateTexture(m_sdl_renderer,
1669+ SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING,
1670+ w, h);
1671+ screen_.reset(new SDLSurface(m_sdl_screen, false));
1672 }
1673
1674- m_sdl_screen = sdlsurface;
1675 m_rendertarget.reset(new RenderTarget(screen_.get()));
1676
1677 pic_road_normal_.reset(load_image("world/pics/roadt_normal.png"));
1678@@ -337,8 +341,25 @@
1679 if (UI::g_fh)
1680 UI::g_fh->flush();
1681
1682- if (g_opengl)
1683+ if (g_opengl) {
1684 GLSurfaceTexture::cleanup();
1685+ }
1686+ if (m_sdl_texture) {
1687+ SDL_DestroyTexture(m_sdl_texture);
1688+ m_sdl_texture = nullptr;
1689+ }
1690+ if (m_sdl_screen) {
1691+ SDL_FreeSurface(m_sdl_screen);
1692+ m_sdl_screen = nullptr;
1693+ }
1694+ if (m_sdlwindow) {
1695+ SDL_DestroyWindow(m_sdlwindow);
1696+ m_sdlwindow = nullptr;
1697+ }
1698+ if (m_glcontext) {
1699+ SDL_GL_DeleteContext(m_glcontext);
1700+ m_glcontext = nullptr;
1701+ }
1702 }
1703
1704 Graphic::~Graphic()
1705@@ -364,7 +385,7 @@
1706
1707 bool Graphic::is_fullscreen()
1708 {
1709- return m_sdl_screen->flags & SDL_FULLSCREEN;
1710+ return SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN;
1711 }
1712
1713 /**
1714@@ -390,32 +411,16 @@
1715 // Note: Not all Images are cached in the ImageCache, at time of me writing
1716 // this, only InMemoryImage does not safe itself in the ImageCache. And this
1717 // should only be a problem for Images loaded from maps.
1718- SDL_WM_ToggleFullScreen(m_sdl_screen);
1719-}
1720-
1721-/**
1722- * Mark the entire screen for refreshing
1723-*/
1724-void Graphic::update_fullscreen()
1725-{
1726- m_update_fullscreen = true;
1727-}
1728-
1729-/**
1730- * Mark a rectangle for refreshing
1731-*/
1732-void Graphic::update_rectangle(int32_t x, int32_t y, int32_t w, int32_t h)
1733-{
1734- if (m_nr_update_rects >= MAX_RECTS) {
1735- m_update_fullscreen = true;
1736- return;
1737+ if (SDL_GetWindowFlags(m_sdlwindow) & SDL_WINDOW_FULLSCREEN) {
1738+ SDL_SetWindowFullscreen(m_sdlwindow, 0);
1739+ } else {
1740+ SDL_SetWindowFullscreen(m_sdlwindow, SDL_WINDOW_FULLSCREEN);
1741 }
1742- m_update_fullscreen = true;
1743- m_update_rects[m_nr_update_rects].x = x;
1744- m_update_rects[m_nr_update_rects].y = y;
1745- m_update_rects[m_nr_update_rects].w = w;
1746- m_update_rects[m_nr_update_rects].h = h;
1747- ++m_nr_update_rects;
1748+}
1749+
1750+
1751+void Graphic::update() {
1752+ m_update = true;
1753 }
1754
1755 /**
1756@@ -423,7 +428,7 @@
1757 */
1758 bool Graphic::need_update() const
1759 {
1760- return m_nr_update_rects || m_update_fullscreen;
1761+ return m_update;
1762 }
1763
1764 /**
1765@@ -431,24 +436,19 @@
1766 *
1767 * \param force update whole screen
1768 */
1769-void Graphic::refresh(bool force)
1770+void Graphic::refresh()
1771 {
1772 if (g_opengl) {
1773- SDL_GL_SwapBuffers();
1774- m_update_fullscreen = false;
1775- m_nr_update_rects = 0;
1776+ SDL_GL_SwapWindow(m_sdlwindow);
1777+ m_update = false;
1778 return;
1779 }
1780
1781- if (force || m_update_fullscreen) {
1782- //flip defaults to SDL_UpdateRect(m_surface, 0, 0, 0, 0);
1783- SDL_Flip(m_sdl_screen);
1784- } else
1785- SDL_UpdateRects
1786- (m_sdl_screen, m_nr_update_rects, m_update_rects);
1787-
1788- m_update_fullscreen = false;
1789- m_nr_update_rects = 0;
1790+ SDL_UpdateTexture(m_sdl_texture, nullptr, m_sdl_screen->pixels, m_sdl_screen->pitch);
1791+ SDL_RenderClear(m_sdl_renderer);
1792+ SDL_RenderCopy(m_sdl_renderer, m_sdl_texture, nullptr, nullptr);
1793+ SDL_RenderPresent(m_sdl_renderer);
1794+ m_update = false;
1795 }
1796
1797
1798@@ -464,7 +464,11 @@
1799
1800 uint32_t Graphic::new_maptexture(const std::vector<std::string>& texture_files, const uint32_t frametime)
1801 {
1802- m_maptextures.emplace_back(new Texture(texture_files, frametime, *m_sdl_screen->format));
1803+ SDL_PixelFormat* pixel_fmt = SDL_AllocFormat(SDL_PIXELFORMAT_ARGB8888);
1804+ m_maptextures.emplace_back(new Texture(texture_files, frametime, *pixel_fmt));
1805+ if (pixel_fmt) {
1806+ SDL_FreeFormat(pixel_fmt);
1807+ }
1808 return m_maptextures.size(); // ID 1 is at m_maptextures[0]
1809 }
1810
1811
1812=== modified file 'src/graphic/graphic.h'
1813--- src/graphic/graphic.h 2014-09-27 13:29:32 +0000
1814+++ src/graphic/graphic.h 2014-11-02 20:06:40 +0000
1815@@ -89,13 +89,10 @@
1816
1817 RenderTarget * get_render_target();
1818 void toggle_fullscreen();
1819- void update_fullscreen();
1820- void update_rectangle(int32_t x, int32_t y, int32_t w, int32_t h);
1821- void update_rectangle(const Rect& rect) {
1822- update_rectangle (rect.x, rect.y, rect.w, rect.h);
1823- }
1824+ void update();
1825 bool need_update() const;
1826- void refresh(bool force = true);
1827+ void refresh();
1828+ SDL_Window* get_sdlwindow() {return m_sdlwindow;}
1829
1830 SurfaceCache& surfaces() const {return *surface_cache_.get();}
1831 ImageCache& images() const {return *image_cache_.get();}
1832@@ -130,15 +127,14 @@
1833 /// opengl rendering as the SurfaceOpenGL does not use it. It allows
1834 /// manipulation the screen context.
1835 SDL_Surface * m_sdl_screen;
1836+ SDL_Renderer * m_sdl_renderer;
1837+ SDL_Window * m_sdlwindow;
1838+ SDL_Texture * m_sdl_texture;
1839+ SDL_GLContext m_glcontext;
1840 /// A RenderTarget for screen_. This is initialized during init()
1841 std::unique_ptr<RenderTarget> m_rendertarget;
1842- /// keeps track which screen regions needs to be redrawn during the next
1843- /// update(). Only used for SDL rendering.
1844- SDL_Rect m_update_rects[MAX_RECTS];
1845- /// saves how many screen regions need updating. @see m_update_rects
1846- int32_t m_nr_update_rects;
1847- /// This marks the komplete screen for updating.
1848- bool m_update_fullscreen;
1849+ /// This marks the complete screen for updating.
1850+ bool m_update;
1851 /// stores which features the current renderer has
1852 GraphicCaps m_caps;
1853
1854
1855=== modified file 'src/graphic/image_transformations.cc'
1856--- src/graphic/image_transformations.cc 2014-09-27 18:53:55 +0000
1857+++ src/graphic/image_transformations.cc 2014-11-02 20:06:40 +0000
1858@@ -22,7 +22,7 @@
1859 #include <string>
1860
1861 #include <SDL.h>
1862-#include <SDL_rotozoom.h>
1863+#include <SDL2_rotozoom.h>
1864 #include <boost/format.hpp>
1865
1866 #include "base/macros.h"
1867@@ -129,7 +129,8 @@
1868 static_cast<uint16_t>(zoomed->w), static_cast<uint16_t>(zoomed->h)
1869 }; // For some reason SDL_Surface and SDL_Rect express w,h in different types
1870 SDL_Rect dstrc = {0, 0, 0, 0};
1871- SDL_SetAlpha(zoomed, 0, 0);
1872+ SDL_SetSurfaceAlphaMod(zoomed, SDL_ALPHA_TRANSPARENT);
1873+ SDL_SetSurfaceBlendMode(zoomed, SDL_BLENDMODE_NONE);
1874 SDL_BlitSurface(zoomed, &srcrc, placed, &dstrc); // Updates dstrc
1875
1876 uint32_t fillcolor = SDL_MapRGBA(zoomed->format, 0, 0, 0, 255);
1877
1878=== modified file 'src/graphic/sdl/surface.cc'
1879--- src/graphic/sdl/surface.cc 2014-09-27 18:53:55 +0000
1880+++ src/graphic/sdl/surface.cc 2014-11-02 20:06:40 +0000
1881@@ -338,14 +338,18 @@
1882 bool alpha = false;
1883 uint8_t alphaval = 0;
1884 if (cm == CM_Solid || cm == CM_Copy) {
1885- alpha = sdlsurf->flags & SDL_SRCALPHA;
1886- alphaval = sdlsurf->format->alpha;
1887- SDL_SetAlpha(sdlsurf, 0, 0);
1888+ SDL_BlendMode bm;
1889+ SDL_GetSurfaceBlendMode(sdlsurf, &bm);
1890+ alpha = bm & SDL_BLENDMODE_BLEND;
1891+ SDL_GetSurfaceAlphaMod(sdlsurf, &alphaval);
1892+ SDL_SetSurfaceAlphaMod(sdlsurf, 255);
1893+ SDL_SetSurfaceBlendMode(sdlsurf, SDL_BLENDMODE_NONE);
1894 }
1895
1896 SDL_BlitSurface(sdlsurf, &srcrect, m_surface, &dstrect);
1897
1898 if (cm == CM_Solid || cm == CM_Copy) {
1899- SDL_SetAlpha(sdlsurf, alpha ? SDL_SRCALPHA : 0, alphaval);
1900+ SDL_SetSurfaceAlphaMod(sdlsurf, alphaval);
1901+ SDL_SetSurfaceBlendMode(sdlsurf, alpha ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE);
1902 }
1903 }
1904
1905=== modified file 'src/graphic/sdl/surface.h'
1906--- src/graphic/sdl/surface.h 2014-09-27 18:53:55 +0000
1907+++ src/graphic/sdl/surface.h 2014-11-02 20:06:40 +0000
1908@@ -20,6 +20,8 @@
1909 #ifndef WL_GRAPHIC_SDL_SURFACE_H
1910 #define WL_GRAPHIC_SDL_SURFACE_H
1911
1912+#include <SDL_render.h>
1913+
1914 #include "base/rect.h"
1915 #include "graphic/color.h"
1916 #include "graphic/surface.h"
1917
1918=== modified file 'src/graphic/surface.cc'
1919--- src/graphic/surface.cc 2014-09-27 18:53:55 +0000
1920+++ src/graphic/surface.cc 2014-11-02 20:06:40 +0000
1921@@ -35,7 +35,7 @@
1922 if (!s_is_diplay_format_defined) {
1923 return surface;
1924 }
1925- SDL_Surface * converted = SDL_DisplayFormatAlpha(surface);
1926+ SDL_Surface * converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
1927 SDL_FreeSurface(surface);
1928 return converted;
1929 }
1930
1931=== modified file 'src/graphic/text/CMakeLists.txt'
1932--- src/graphic/text/CMakeLists.txt 2014-07-14 10:45:44 +0000
1933+++ src/graphic/text/CMakeLists.txt 2014-11-02 20:06:40 +0000
1934@@ -14,9 +14,9 @@
1935 sdl_ttf_font.h
1936 textstream.cc
1937 textstream.h
1938- USES_SDL
1939- USES_SDL_TTF
1940- USES_SDL_GFX
1941+ USES_SDL2
1942+ USES_SDL2_TTF
1943+ USES_SDL2_GFX
1944 DEPENDS
1945 base_exceptions
1946 base_geometry
1947
1948=== modified file 'src/graphic/text/sdl_ttf_font.cc'
1949--- src/graphic/text/sdl_ttf_font.cc 2014-09-27 18:53:55 +0000
1950+++ src/graphic/text/sdl_ttf_font.cc 2014-11-02 20:06:40 +0000
1951@@ -19,6 +19,7 @@
1952
1953 #include "graphic/text/sdl_ttf_font.h"
1954
1955+#include <SDL.h>
1956 #include <SDL_ttf.h>
1957 #include <boost/format.hpp>
1958
1959@@ -70,20 +71,21 @@
1960
1961 SDL_Surface * text_surface = nullptr;
1962
1963- SDL_Color sdlclr = {clr.r, clr.g, clr.b, 0};
1964+ SDL_Color sdlclr = {clr.r, clr.g, clr.b, SDL_ALPHA_OPAQUE};
1965 if (style & SHADOW) {
1966 SDL_Surface * tsurf = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
1967 SDL_Surface * shadow = TTF_RenderUTF8_Blended(font_, txt.c_str(), SHADOW_CLR);
1968 text_surface = empty_sdl_surface(shadow->w + SHADOW_OFFSET, shadow->h + SHADOW_OFFSET);
1969 SDL_FillRect(text_surface,
1970 NULL,
1971- SDL_MapRGBA(text_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
1972+ SDL_MapRGBA(text_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
1973
1974 if (text_surface->format->BitsPerPixel != 32)
1975 throw RenderError("SDL_TTF did not return a 32 bit surface for shadow text. Giving up!");
1976
1977 SDL_Rect dstrct1 = {0, 0, 0, 0};
1978- SDL_SetAlpha(shadow, 0, SDL_ALPHA_OPAQUE);
1979+ SDL_SetSurfaceAlphaMod(shadow, SDL_ALPHA_OPAQUE);
1980+ SDL_SetSurfaceBlendMode(shadow, SDL_BLENDMODE_NONE);
1981 SDL_BlitSurface(shadow, nullptr, text_surface, &dstrct1);
1982
1983 uint32_t* spix = static_cast<uint32_t*>(tsurf->pixels);
1984
1985=== modified file 'src/io/CMakeLists.txt'
1986--- src/io/CMakeLists.txt 2014-07-26 16:16:21 +0000
1987+++ src/io/CMakeLists.txt 2014-11-02 20:06:40 +0000
1988@@ -7,7 +7,7 @@
1989 streamread.h
1990 streamwrite.cc
1991 streamwrite.h
1992- USES_SDL
1993+ USES_SDL2
1994 DEPENDS
1995 base_exceptions
1996 base_macros
1997
1998=== modified file 'src/logic/CMakeLists.txt'
1999--- src/logic/CMakeLists.txt 2014-09-18 18:56:20 +0000
2000+++ src/logic/CMakeLists.txt 2014-11-02 20:06:40 +0000
2001@@ -1,7 +1,7 @@
2002 wl_binary(wl_map_info
2003 SRCS
2004 map_info.cc
2005- USES_SDL
2006+ USES_SDL2
2007 DEPENDS
2008 base_log
2009 graphic
2010@@ -211,8 +211,8 @@
2011 world/terrain_description.h
2012 world/world.cc
2013 world/world.h
2014- # TODO(sirver): Uses SDL only on WIN32 for a dirty hack.
2015- USES_SDL
2016+ # TODO(sirver): Uses SDL2 only on WIN32 for a dirty hack.
2017+ USES_SDL2
2018 DEPENDS
2019 ai
2020 base_deprecated
2021
2022=== modified file 'src/map_io/CMakeLists.txt'
2023--- src/map_io/CMakeLists.txt 2014-09-10 07:57:29 +0000
2024+++ src/map_io/CMakeLists.txt 2014-11-02 20:06:40 +0000
2025@@ -84,7 +84,7 @@
2026 map_terrain_packet.h
2027 map_version_packet.cc
2028 map_version_packet.h
2029- USES_SDL_IMAGE
2030+ USES_SDL2_IMAGE
2031 DEPENDS
2032 base_deprecated
2033 base_exceptions
2034
2035=== modified file 'src/network/CMakeLists.txt'
2036--- src/network/CMakeLists.txt 2014-07-16 06:41:27 +0000
2037+++ src/network/CMakeLists.txt 2014-11-02 20:06:40 +0000
2038@@ -20,7 +20,7 @@
2039 network_player_settings_backend.h
2040 network_protocol.h
2041 network_system.h
2042- USES_SDL_NET
2043+ USES_SDL2_NET
2044 DEPENDS
2045 ai
2046 base_deprecated
2047
2048=== modified file 'src/sound/CMakeLists.txt'
2049--- src/sound/CMakeLists.txt 2014-07-14 10:45:44 +0000
2050+++ src/sound/CMakeLists.txt 2014-11-02 20:06:40 +0000
2051@@ -7,8 +7,8 @@
2052 sound_handler.cc
2053 sound_handler.h
2054 USES_BOOST_REGEX
2055- USES_SDL
2056- USES_SDL_MIXER
2057+ USES_SDL2
2058+ USES_SDL2_MIXER
2059 DEPENDS
2060 base_deprecated
2061 base_i18n
2062
2063=== modified file 'src/sound/songset.cc'
2064--- src/sound/songset.cc 2014-09-20 09:37:47 +0000
2065+++ src/sound/songset.cc 2014-11-02 20:06:40 +0000
2066@@ -26,20 +26,6 @@
2067 #include "io/filesystem/layered_filesystem.h"
2068 #include "sound/sound_handler.h"
2069
2070-namespace {
2071- // The behaviour of whether SDL_Mixer frees the RW it uses was
2072- // changed with SDL_Mixer version 1.2.12, this
2073- // check is so that we don't have a memory leak in the new version.
2074- // TODO(unknown): Once we can demand that everyone use
2075- // SDL_Mixer version >= 1.2.12, this function should be removed,
2076- // and all usages replaced supposing it's true.
2077- bool have_to_free_rw() {
2078- return
2079- SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) >=
2080- SDL_VERSIONNUM(1, 2, 12);
2081- }
2082-}
2083-
2084 /// Prepare infrastructure for reading song files from disk
2085 Songset::Songset() : m_(nullptr), rwops_(nullptr) {}
2086
2087@@ -52,8 +38,7 @@
2088 Mix_FreeMusic(m_);
2089
2090 if (rwops_) {
2091- if (have_to_free_rw())
2092- SDL_FreeRW(rwops_);
2093+ SDL_FreeRW(rwops_);
2094 fr_.close();
2095 }
2096 }
2097@@ -98,8 +83,7 @@
2098 }
2099
2100 if (rwops_) {
2101- if (have_to_free_rw())
2102- SDL_FreeRW(rwops_);
2103+ SDL_FreeRW(rwops_);
2104 rwops_ = nullptr;
2105 fr_.close();
2106 }
2107@@ -115,7 +99,7 @@
2108 return nullptr;
2109
2110 if (rwops_)
2111- m_ = Mix_LoadMUS_RW(rwops_);
2112+ m_ = Mix_LoadMUS_RW(rwops_, 0);
2113
2114 if (m_)
2115 log("SoundHandler: loaded song \"%s\"\n", filename.c_str());
2116
2117=== modified file 'src/sound/sound_handler.cc'
2118--- src/sound/sound_handler.cc 2014-09-20 09:37:47 +0000
2119+++ src/sound/sound_handler.cc 2014-11-02 20:06:40 +0000
2120@@ -164,11 +164,8 @@
2121 if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {
2122 log ("audio error %s\n", SDL_GetError());
2123 }
2124- char * text = new char[21];
2125- SDL_AudioDriverName(text, 20);
2126- log("SDL_AUDIODRIVER %s\n", text);
2127- delete[] text;
2128- text = nullptr;
2129+
2130+ log("SDL_AUDIODRIVER %s\n", SDL_GetCurrentAudioDriver());
2131
2132 if (numtimesopened != 1) {
2133 log ("PROBLEM: sound device opened multiple times, trying to close");
2134
2135=== modified file 'src/ui_basic/CMakeLists.txt'
2136--- src/ui_basic/CMakeLists.txt 2014-07-15 10:02:22 +0000
2137+++ src/ui_basic/CMakeLists.txt 2014-11-02 20:06:40 +0000
2138@@ -51,7 +51,7 @@
2139 window.cc
2140 window.h
2141 USES_BOOST_REGEX
2142- USES_SDL
2143+ USES_SDL2
2144 DEPENDS
2145 base_deprecated
2146 base_exceptions
2147
2148=== modified file 'src/ui_basic/button.cc'
2149--- src/ui_basic/button.cc 2014-07-25 18:56:22 +0000
2150+++ src/ui_basic/button.cc 2014-11-02 20:06:40 +0000
2151@@ -341,6 +341,7 @@
2152 }
2153 return true;
2154 }
2155+
2156 bool Button::handle_mousemove(const uint8_t, int32_t, int32_t, int32_t, int32_t) {
2157 return true; // We handle this always by lighting up
2158 }
2159
2160=== modified file 'src/ui_basic/editbox.cc'
2161--- src/ui_basic/editbox.cc 2014-09-19 09:07:14 +0000
2162+++ src/ui_basic/editbox.cc 2014-11-02 20:06:40 +0000
2163@@ -21,7 +21,7 @@
2164
2165 #include <limits>
2166
2167-#include <SDL_keysym.h>
2168+#include <SDL_keycode.h>
2169
2170 #include "graphic/font.h"
2171 #include "graphic/font_handler.h"
2172@@ -87,6 +87,7 @@
2173
2174 set_handle_mouse(true);
2175 set_can_focus(true);
2176+ set_handle_textinput(true);
2177
2178 // Initialize history as empty string
2179 for (uint8_t i = 0; i < CHAT_HISTORY_SIZE; ++i)
2180@@ -220,7 +221,7 @@
2181 // TODO(unknown): Text input works only because code.unicode happens to map to ASCII for
2182 // ASCII characters (--> //HERE). Instead, all user editable strings should be
2183 // real unicode.
2184-bool EditBox::handle_key(bool const down, SDL_keysym const code)
2185+bool EditBox::handle_key(bool const down, SDL_Keysym const code)
2186 {
2187 if (down) {
2188 switch (code.sym) {
2189@@ -232,7 +233,7 @@
2190 //let the panel handle the tab key
2191 return false;
2192
2193- case SDLK_KP_ENTER:
2194+ case SDL_SCANCODE_KP_ENTER:
2195 case SDLK_RETURN:
2196 // Save history if active and text is not empty
2197 if (m_history_active) {
2198@@ -246,9 +247,8 @@
2199 ok();
2200 return true;
2201
2202- case SDLK_KP_PERIOD:
2203+ case SDL_SCANCODE_KP_PERIOD:
2204 if (code.mod & KMOD_NUM) {
2205- insert(code);
2206 break;
2207 }
2208 /* no break */
2209@@ -270,13 +270,12 @@
2210 }
2211 return true;
2212
2213- case SDLK_KP4:
2214+ case SDL_SCANCODE_KP_4:
2215 if (code.mod & KMOD_NUM) {
2216- insert(code);
2217 break;
2218 }
2219 /* no break */
2220- case SDLK_LEFT:
2221+ case SDL_SCANCODE_LEFT:
2222 if (m->caret > 0) {
2223 while ((m->text[--m->caret] & 0xc0) == 0x80) {};
2224 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
2225@@ -290,13 +289,12 @@
2226 }
2227 return true;
2228
2229- case SDLK_KP6:
2230+ case SDL_SCANCODE_KP_6:
2231 if (code.mod & KMOD_NUM) {
2232- insert(code);
2233 break;
2234 }
2235 /* no break */
2236- case SDLK_RIGHT:
2237+ case SDL_SCANCODE_RIGHT:
2238 if (m->caret < m->text.size()) {
2239 while ((m->text[++m->caret] & 0xc0) == 0x80) {};
2240 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
2241@@ -315,9 +313,8 @@
2242 }
2243 return true;
2244
2245- case SDLK_KP7:
2246+ case SDL_SCANCODE_KP_7:
2247 if (code.mod & KMOD_NUM) {
2248- insert(code);
2249 break;
2250 }
2251 /* no break */
2252@@ -330,9 +327,8 @@
2253 }
2254 return true;
2255
2256- case SDLK_KP1:
2257+ case SDL_SCANCODE_KP_1:
2258 if (code.mod & KMOD_NUM) {
2259- insert(code);
2260 break;
2261 }
2262 /* no break */
2263@@ -344,13 +340,12 @@
2264 }
2265 return true;
2266
2267- case SDLK_KP8:
2268+ case SDL_SCANCODE_KP_8:
2269 if (code.mod & KMOD_NUM) {
2270- insert(code);
2271 break;
2272 }
2273 /* no break */
2274- case SDLK_UP:
2275+ case SDL_SCANCODE_UP:
2276 // Load entry from history if active and text is not empty
2277 if (m_history_active) {
2278 if (m_history_position > CHAT_HISTORY_SIZE - 2)
2279@@ -364,13 +359,12 @@
2280 }
2281 return true;
2282
2283- case SDLK_KP2:
2284+ case SDL_SCANCODE_KP_2:
2285 if (code.mod & KMOD_NUM) {
2286- insert(code);
2287 break;
2288 }
2289 /* no break */
2290- case SDLK_DOWN:
2291+ case SDL_SCANCODE_DOWN:
2292 // Load entry from history if active and text is not equivalent to the current one
2293 if (m_history_active) {
2294 if (m_history_position < 1)
2295@@ -384,16 +378,7 @@
2296 }
2297 return true;
2298
2299-
2300 default:
2301- // Nullbytes happen on MacOS X when entering Multiline Chars, like for
2302- // example ~ + o results in a o with a tilde over it. The ~ is reported
2303- // as a 0 on keystroke, the o then as the unicode character. We simply
2304- // ignore the 0.
2305- if (is_printable(code) && code.unicode) {
2306- insert(code);
2307- return true;
2308- }
2309 break;
2310 }
2311 }
2312@@ -401,31 +386,16 @@
2313 return false;
2314 }
2315
2316-/**
2317- * Insert the utf8 character according to the specified key code
2318- */
2319-void EditBox::insert(SDL_keysym const code)
2320-{
2321- if (m->text.size() < m->maxLength) {
2322- if (code.unicode < 0x80) // 1 byte char
2323- m->text.insert(m->text.begin() + m->caret++, 1, code.unicode);
2324- else if (code.unicode < 0x800) { // 2 byte char
2325- m->text.insert
2326- (m->text.begin() + m->caret++, (((code.unicode & 0x7c0) >> 6) | 0xc0));
2327- m->text.insert
2328- (m->text.begin() + m->caret++, ((code.unicode & 0x3f) | 0x80));
2329- } else { // 3 byte char
2330- m->text.insert
2331- (m->text.begin() + m->caret++, (((code.unicode & 0xf000) >> 12) | 0xe0));
2332- m->text.insert
2333- (m->text.begin() + m->caret++, (((code.unicode & 0xfc0) >> 6) | 0x80));
2334- m->text.insert
2335- (m->text.begin() + m->caret++, ((code.unicode & 0x3f) | 0x80));
2336- }
2337+bool EditBox::handle_textinput(const char * ntext) {
2338+ const std::string help(ntext);
2339+ if ((m->text.size() + help.length()) < m->maxLength) {
2340+ m->text.insert(m->caret, help);
2341+ m->caret += help.length();
2342 check_caret();
2343 changed();
2344 update();
2345 }
2346+ return true;
2347 }
2348
2349 void EditBox::draw(RenderTarget & odst)
2350
2351=== modified file 'src/ui_basic/editbox.h'
2352--- src/ui_basic/editbox.h 2014-09-19 09:07:14 +0000
2353+++ src/ui_basic/editbox.h 2014-11-02 20:06:40 +0000
2354@@ -61,7 +61,8 @@
2355
2356 bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
2357 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
2358- bool handle_key(bool down, SDL_keysym) override;
2359+ bool handle_key(bool down, SDL_Keysym) override;
2360+ bool handle_textinput(const char* text);
2361
2362 void draw(RenderTarget &) override;
2363
2364@@ -69,7 +70,6 @@
2365 std::unique_ptr<EditBoxImpl> m;
2366
2367 void check_caret();
2368- void insert(SDL_keysym code);
2369
2370 bool m_history_active;
2371 int16_t m_history_position;
2372
2373=== modified file 'src/ui_basic/is_printable.cc'
2374--- src/ui_basic/is_printable.cc 2014-07-03 20:11:14 +0000
2375+++ src/ui_basic/is_printable.cc 2014-11-02 20:06:40 +0000
2376@@ -21,10 +21,9 @@
2377
2378 namespace UI {
2379
2380-bool is_printable(SDL_keysym k) {
2381+bool is_printable(SDL_Keysym k) {
2382 return (k.sym == SDLK_TAB) || ((k.sym >= SDLK_SPACE) && (k.sym <= SDLK_z)) ||
2383- ((k.sym >= SDLK_WORLD_0) && (k.sym <= SDLK_WORLD_95)) ||
2384- ((k.sym >= SDLK_KP0) && (k.sym <= SDLK_KP_EQUALS));
2385+ ((k.sym >= SDL_SCANCODE_KP_0) && (k.sym <= SDL_SCANCODE_KP_EQUALS));
2386 }
2387
2388 } // namespace UI
2389
2390=== modified file 'src/ui_basic/is_printable.h'
2391--- src/ui_basic/is_printable.h 2014-07-23 14:49:10 +0000
2392+++ src/ui_basic/is_printable.h 2014-11-02 20:06:40 +0000
2393@@ -36,7 +36,7 @@
2394 // WLApplication::init_hardware()) instead of k.sym. Doing so needs to take the
2395 // current locale into account; perhaps there already is a fitting gettext
2396 // function?
2397-bool is_printable(SDL_keysym k);
2398+bool is_printable(SDL_Keysym k);
2399
2400 } // namespace UI
2401
2402
2403=== modified file 'src/ui_basic/listselect.cc'
2404--- src/ui_basic/listselect.cc 2014-10-27 10:31:04 +0000
2405+++ src/ui_basic/listselect.cc 2014-11-02 20:06:40 +0000
2406@@ -416,14 +416,19 @@
2407 }
2408
2409 /**
2410+ * Handle mouse wheel events
2411+ */
2412+bool BaseListselect::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
2413+ return m_scrollbar.handle_mousewheel(which, x, y);
2414+}
2415+
2416+/**
2417 * Handle mouse presses: select the appropriate entry
2418 */
2419 bool BaseListselect::handle_mousepress(const uint8_t btn, int32_t, int32_t y)
2420 {
2421 switch (btn) {
2422- case SDL_BUTTON_WHEELDOWN:
2423- case SDL_BUTTON_WHEELUP:
2424- return m_scrollbar.handle_mousepress(btn, 0, y);
2425+
2426 case SDL_BUTTON_LEFT: {
2427 int32_t const time = WLApplication::get()->get_time();
2428
2429@@ -471,15 +476,15 @@
2430 return true;
2431 }
2432
2433-bool BaseListselect::handle_key(bool const down, SDL_keysym const code) {
2434+bool BaseListselect::handle_key(bool const down, SDL_Keysym const code) {
2435 if (down) {
2436 uint32_t selected_idx;
2437 switch (code.sym) {
2438- case SDLK_KP2:
2439+ case SDL_SCANCODE_KP_2:
2440 if (code.mod & KMOD_NUM)
2441 break;
2442 /* no break */
2443- case SDLK_DOWN:
2444+ case SDL_SCANCODE_DOWN:
2445 selected_idx = selection_index() + 1;
2446 if (selected_idx < size())
2447 select(selected_idx);
2448@@ -489,11 +494,11 @@
2449 m_scrollbar.set_scrollpos(m_scrollpos);
2450 }
2451 return true;
2452- case SDLK_KP8:
2453+ case SDL_SCANCODE_KP_8:
2454 if (code.mod & KMOD_NUM)
2455 break;
2456 /* no break */
2457- case SDLK_UP:
2458+ case SDL_SCANCODE_UP:
2459 selected_idx = selection_index();
2460 if (selected_idx > 0)
2461 select(selected_idx - 1);
2462
2463=== modified file 'src/ui_basic/listselect.h'
2464--- src/ui_basic/listselect.h 2014-10-27 10:31:04 +0000
2465+++ src/ui_basic/listselect.h 2014-11-02 20:06:40 +0000
2466@@ -117,7 +117,8 @@
2467 bool handle_mousepress (uint8_t btn, int32_t x, int32_t y) override;
2468 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
2469 bool handle_mousemove (uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff) override;
2470- bool handle_key(bool down, SDL_keysym) override;
2471+ bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
2472+ bool handle_key(bool down, SDL_Keysym) override;
2473
2474 private:
2475 static const int32_t DOUBLE_CLICK_INTERVAL = 500; // half a second
2476
2477=== modified file 'src/ui_basic/messagebox.cc'
2478--- src/ui_basic/messagebox.cc 2014-09-19 09:07:14 +0000
2479+++ src/ui_basic/messagebox.cc 2014-11-02 20:06:40 +0000
2480@@ -133,14 +133,14 @@
2481 return true;
2482 }
2483
2484-bool WLMessageBox::handle_key(bool down, SDL_keysym code)
2485+bool WLMessageBox::handle_key(bool down, SDL_Keysym code)
2486 {
2487 if (!down) {
2488 return false;
2489 }
2490
2491 switch (code.sym) {
2492- case SDLK_KP_ENTER:
2493+ case SDL_SCANCODE_KP_ENTER:
2494 case SDLK_RETURN:
2495 pressed_yes();
2496 pressed_ok();
2497
2498=== modified file 'src/ui_basic/messagebox.h'
2499--- src/ui_basic/messagebox.h 2014-09-19 09:07:14 +0000
2500+++ src/ui_basic/messagebox.h 2014-11-02 20:06:40 +0000
2501@@ -69,7 +69,7 @@
2502
2503 bool handle_mousepress (uint8_t btn, int32_t mx, int32_t my) override;
2504 bool handle_mouserelease(uint8_t btn, int32_t mx, int32_t my) override;
2505- bool handle_key(bool down, SDL_keysym code) override;
2506+ bool handle_key(bool down, SDL_Keysym code) override;
2507
2508 protected:
2509 virtual void pressed_ok();
2510
2511=== modified file 'src/ui_basic/multilineeditbox.cc'
2512--- src/ui_basic/multilineeditbox.cc 2014-09-10 14:48:40 +0000
2513+++ src/ui_basic/multilineeditbox.cc 2014-11-02 20:06:40 +0000
2514@@ -89,6 +89,7 @@
2515 set_handle_mouse(true);
2516 set_can_focus(true);
2517 set_think(false);
2518+ set_handle_textinput(true);
2519
2520 set_text(text);
2521 }
2522@@ -245,27 +246,15 @@
2523 return cursor;
2524 }
2525
2526-/**
2527- * Insert the utf8 character according to the specified key code
2528- */
2529-void MultilineEditbox::insert(SDL_keysym const code)
2530-{
2531- std::string utf8 = Utf8::unicode_to_utf8(code.unicode);
2532-
2533- if (d->text.size() + utf8.size() <= d->maxbytes) {
2534- d->insert(d->cursor_pos, utf8);
2535- changed();
2536- }
2537-}
2538
2539 /**
2540 * This is called by the UI code whenever a key press or release arrives
2541 */
2542-bool MultilineEditbox::handle_key(bool const down, SDL_keysym const code)
2543+bool MultilineEditbox::handle_key(bool const down, SDL_Keysym const code)
2544 {
2545 if (down) {
2546 switch (code.sym) {
2547- case SDLK_KP_PERIOD:
2548+ case SDL_SCANCODE_KP_PERIOD:
2549 if (code.mod & KMOD_NUM)
2550 break;
2551 /* no break */
2552@@ -283,13 +272,12 @@
2553 }
2554 break;
2555
2556- case SDLK_KP4:
2557+ case SDL_SCANCODE_KP_4:
2558 if (code.mod & KMOD_NUM) {
2559- insert(code);
2560 break;
2561 }
2562 /* no break */
2563- case SDLK_LEFT: {
2564+ case SDL_SCANCODE_LEFT: {
2565 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
2566 uint32_t newpos = d->prev_char(d->cursor_pos);
2567 while (newpos > 0 && isspace(d->text[newpos]))
2568@@ -307,13 +295,12 @@
2569 break;
2570 }
2571
2572- case SDLK_KP6:
2573+ case SDL_SCANCODE_KP_6:
2574 if (code.mod & KMOD_NUM) {
2575- insert(code);
2576 break;
2577 }
2578 /* no break */
2579- case SDLK_RIGHT:
2580+ case SDL_SCANCODE_RIGHT:
2581 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
2582 uint32_t newpos = d->next_char(d->cursor_pos);
2583 while (newpos < d->text.size() && isspace(d->text[newpos]))
2584@@ -326,13 +313,12 @@
2585 }
2586 break;
2587
2588- case SDLK_KP2:
2589+ case SDL_SCANCODE_KP_2:
2590 if (code.mod & KMOD_NUM) {
2591- insert(code);
2592 break;
2593 }
2594 /* no break */
2595- case SDLK_DOWN:
2596+ case SDL_SCANCODE_DOWN:
2597 if (d->cursor_pos < d->text.size()) {
2598 d->refresh_ww();
2599
2600@@ -356,13 +342,12 @@
2601 }
2602 break;
2603
2604- case SDLK_KP8:
2605+ case SDL_SCANCODE_KP_8:
2606 if (code.mod & KMOD_NUM) {
2607- insert(code);
2608 break;
2609 }
2610 /* no break */
2611- case SDLK_UP:
2612+ case SDL_SCANCODE_UP:
2613 if (d->cursor_pos > 0) {
2614 d->refresh_ww();
2615
2616@@ -384,9 +369,8 @@
2617 }
2618 break;
2619
2620- case SDLK_KP7:
2621+ case SDL_SCANCODE_KP_7:
2622 if (code.mod & KMOD_NUM) {
2623- insert(code);
2624 break;
2625 }
2626 /* no break */
2627@@ -403,9 +387,8 @@
2628 }
2629 break;
2630
2631- case SDLK_KP1:
2632+ case SDL_SCANCODE_KP_1:
2633 if (code.mod & KMOD_NUM) {
2634- insert(code);
2635 break;
2636 }
2637 /* no break */
2638@@ -425,20 +408,13 @@
2639 }
2640 break;
2641
2642- case SDLK_KP_ENTER:
2643+ case SDL_SCANCODE_KP_ENTER:
2644 case SDLK_RETURN:
2645 d->insert(d->cursor_pos, "\n");
2646 changed();
2647 break;
2648
2649 default:
2650- // Nullbytes happen on MacOS X when entering Multiline Chars, like for
2651- // example ~ + o results in a o with a tilde over it. The ~ is reported
2652- // as a 0 on keystroke, the o then as the unicode character. We simply
2653- // ignore the 0.
2654- if (is_printable(code) && code.unicode) {
2655- insert(code);
2656- }
2657 break;
2658 }
2659 return true;
2660@@ -447,12 +423,21 @@
2661 return Panel::handle_key(down, code);
2662 }
2663
2664+
2665+bool MultilineEditbox::handle_textinput(const char * ntext) {
2666+ const std::string help(ntext);
2667+ if (d->text.size() + help.size() <= d->maxbytes) {
2668+ d->insert(d->cursor_pos, help);
2669+ changed();
2670+ }
2671+ return true;
2672+}
2673+
2674 /**
2675 * Grab the focus and redraw.
2676 */
2677-void MultilineEditbox::focus() {
2678- Panel::focus();
2679-
2680+void MultilineEditbox::focus(bool topcaller) {
2681+ Panel::focus(topcaller);
2682 update();
2683 }
2684
2685
2686=== modified file 'src/ui_basic/multilineeditbox.h'
2687--- src/ui_basic/multilineeditbox.h 2014-09-10 14:48:40 +0000
2688+++ src/ui_basic/multilineeditbox.h 2014-11-02 20:06:40 +0000
2689@@ -47,16 +47,16 @@
2690 void set_maximum_bytes(uint32_t n);
2691 uint32_t get_maximum_bytes() const;
2692
2693- void focus() override;
2694+ void focus(bool topcaller = true) override;
2695
2696 protected:
2697 void draw(RenderTarget &) override;
2698
2699- bool handle_key(bool down, SDL_keysym) override;
2700+ bool handle_key(bool down, SDL_Keysym) override;
2701+ bool handle_textinput(const char* text);
2702
2703 private:
2704 void scrollpos_changed(int32_t);
2705- void insert(SDL_keysym code);
2706
2707 struct Data;
2708 std::unique_ptr<Data> d;
2709
2710=== modified file 'src/ui_basic/multilinetextarea.cc'
2711--- src/ui_basic/multilinetextarea.cc 2014-10-05 13:37:03 +0000
2712+++ src/ui_basic/multilinetextarea.cc 2014-11-02 20:06:40 +0000
2713@@ -190,12 +190,9 @@
2714 }
2715 }
2716
2717-bool MultilineTextarea::handle_mousepress
2718- (uint8_t const btn, int32_t const x, int32_t const y)
2719-{
2720- return
2721- btn == SDL_BUTTON_WHEELUP || btn == SDL_BUTTON_WHEELDOWN ?
2722- m_scrollbar.handle_mousepress(btn, x, y) : false;
2723+
2724+bool MultilineTextarea::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
2725+ return m_scrollbar.handle_mousewheel(which, x, y);
2726 }
2727
2728 void MultilineTextarea::scroll_to_top() {
2729
2730=== modified file 'src/ui_basic/multilinetextarea.h'
2731--- src/ui_basic/multilinetextarea.h 2014-10-05 13:37:03 +0000
2732+++ src/ui_basic/multilinetextarea.h 2014-11-02 20:06:40 +0000
2733@@ -64,7 +64,7 @@
2734 // Drawing and event handlers
2735 void draw(RenderTarget &) override;
2736
2737- bool handle_mousepress (uint8_t btn, int32_t x, int32_t y) override;
2738+ bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
2739 void scroll_to_top();
2740
2741 const char * get_font_name() {return m_fontname.c_str();}
2742
2743=== modified file 'src/ui_basic/panel.cc'
2744--- src/ui_basic/panel.cc 2014-10-18 13:39:27 +0000
2745+++ src/ui_basic/panel.cc 2014-11-02 20:06:40 +0000
2746@@ -189,7 +189,7 @@
2747
2748 // Panel-specific startup code. This might call end_modal()!
2749 start();
2750- g_gr->update_fullscreen();
2751+ g_gr->update();
2752
2753 uint32_t minTime;
2754 {
2755@@ -206,7 +206,9 @@
2756 Panel::ui_mousepress,
2757 Panel::ui_mouserelease,
2758 Panel::ui_mousemove,
2759- Panel::ui_key
2760+ Panel::ui_key,
2761+ Panel::ui_textinput,
2762+ Panel::ui_mousewheel
2763 };
2764
2765 app->handle_input(&icb);
2766@@ -240,7 +242,7 @@
2767 SDL_Delay(minTime - diffTime);
2768 }
2769 }
2770- g_gr->update_fullscreen();
2771+ g_gr->update();
2772 end();
2773
2774 // Done
2775@@ -531,7 +533,7 @@
2776 if (h <= 0)
2777 return;
2778
2779- g_gr->update_rectangle(x, y, w, h);
2780+ g_gr->update();
2781 }
2782 }
2783
2784@@ -665,6 +667,18 @@
2785 }
2786
2787 /**
2788+ * Called whenever the user moves the mouse wheel.
2789+ * If the panel doesn't process the mouse-wheel, it is handed to the panel's
2790+ * parent.
2791+ *
2792+ * \return true if the mouseclick was processed, false otherwise
2793+ */
2794+bool Panel::handle_mousewheel(uint32_t, int32_t, int32_t) {
2795+ return false;
2796+}
2797+
2798+
2799+/**
2800 * Called when the mouse is moved while inside the panel
2801 */
2802 bool Panel::handle_mousemove(const uint8_t, int32_t, int32_t, int32_t, int32_t)
2803@@ -672,14 +686,8 @@
2804 return !_tooltip.empty();
2805 }
2806
2807-/**
2808- * Receive a keypress or keyrelease event.
2809- * code is one of the KEY_xxx constants, c is the corresponding printable
2810- * character or 0 for special, unprintable keys.
2811- *
2812- * \return true if the event was processed, false otherwise
2813-*/
2814-bool Panel::handle_key(bool down, SDL_keysym code)
2815+
2816+bool Panel::handle_key(bool down, SDL_Keysym code)
2817 {
2818 if (down) {
2819 if (_focus) {
2820@@ -710,6 +718,12 @@
2821 return false;
2822 }
2823
2824+
2825+bool Panel::handle_textinput(const char *) {
2826+ return false;
2827+}
2828+
2829+
2830 /**
2831 * Called whenever a tooltip could be drawn.
2832 * Return true if the tooltip has been drawn,
2833@@ -783,15 +797,24 @@
2834 }
2835
2836 /**
2837- * Grab the keyboard focus, if it can
2838+ * Grabs the keyboard focus, if it can,
2839+ * topcaller identifies widget at the beginning of the recursion
2840 */
2841-void Panel::focus()
2842+void Panel::focus(bool topcaller)
2843 {
2844 // this assert was deleted, because
2845 // it happens, that a child can focus, but a parent
2846 // can't. but focus is called recursivly
2847 // assert(get_can_focus());
2848
2849+ if (topcaller) {
2850+ if (get_handle_textinput()) {
2851+ if (!SDL_IsTextInputActive()) SDL_StartTextInput();
2852+ } else {
2853+ if (SDL_IsTextInputActive()) SDL_StopTextInput();
2854+ }
2855+ }
2856+
2857 if (!_parent || this == _modal) {
2858 return;
2859 }
2860@@ -799,7 +822,7 @@
2861 return;
2862
2863 _parent->_focus = this;
2864- _parent->focus();
2865+ _parent->focus(false);
2866 }
2867
2868 /**
2869@@ -1008,8 +1031,8 @@
2870 // Some window managers use alt-drag, so we can't only use the alt keys
2871 if
2872 ((!_g_mousegrab) && (btn == SDL_BUTTON_LEFT) &&
2873- ((get_key_state(SDLK_LALT) | get_key_state(SDLK_RALT) |
2874- get_key_state(SDLK_MODE) | get_key_state(SDLK_LSHIFT))))
2875+ ((get_key_state(SDL_SCANCODE_LALT) | get_key_state(SDL_SCANCODE_RALT) |
2876+ get_key_state(SDL_SCANCODE_MODE) | get_key_state(SDL_SCANCODE_LSHIFT))))
2877 if (handle_alt_drag(x, y))
2878 return true;
2879
2880@@ -1024,6 +1047,26 @@
2881 }
2882 return handle_mousepress(btn, x, y);
2883 }
2884+
2885+
2886+bool Panel::do_mousewheel(uint32_t which, int32_t x, int32_t y) {
2887+ if (!_g_allow_user_input) {
2888+ return true;
2889+ }
2890+
2891+ // TODO(GunChleoc): This is just a hack for focussed panels
2892+ // We need to find the actualy scrollable panel beneaththe mouse cursor,
2893+ // so we can have multiple scrollable elements on the same screen
2894+ // e.g. load map with a long desctiprion has 2 of them.
2895+ if (_focus) {
2896+ if (_focus->do_mousewheel(which, x, y))
2897+ return true;
2898+ }
2899+
2900+ return handle_mousewheel(which, x, y);
2901+}
2902+
2903+
2904 bool Panel::do_mouserelease(const uint8_t btn, int32_t x, int32_t y) {
2905 if (!_g_allow_user_input)
2906 return true;
2907@@ -1070,7 +1113,7 @@
2908 * Pass the key event to the focused child.
2909 * If it doesn't process the key, we'll see if we can use the event.
2910 */
2911-bool Panel::do_key(bool const down, SDL_keysym const code)
2912+bool Panel::do_key(bool const down, SDL_Keysym const code)
2913 {
2914 if (!_g_allow_user_input)
2915 return true;
2916@@ -1083,6 +1126,20 @@
2917 return handle_key(down, code);
2918 }
2919
2920+
2921+bool Panel::do_textinput(const char * text) {
2922+ if (!_g_allow_user_input) {
2923+ return true;
2924+ }
2925+ if (_focus) {
2926+ if (_focus->do_textinput(text)) {
2927+ return true;
2928+ }
2929+ }
2930+ return handle_textinput(text);
2931+}
2932+
2933+
2934 bool Panel::do_tooltip()
2935 {
2936 if (_mousein && _mousein->do_tooltip()) {
2937@@ -1094,7 +1151,7 @@
2938 /**
2939 * \return \c true if the given key is currently pressed, or \c false otherwise
2940 */
2941-bool Panel::get_key_state(const SDLKey key) const
2942+bool Panel::get_key_state(const SDL_Scancode key) const
2943 {
2944 return WLApplication::get()->get_key_state(key);
2945 }
2946@@ -1175,11 +1232,8 @@
2947 return;
2948
2949 Panel * p;
2950- uint16_t w = s_default_cursor->width();
2951- uint16_t h = s_default_cursor->height();
2952
2953- g_gr->update_rectangle(x - xdiff, y - ydiff, w, h);
2954- g_gr->update_rectangle(x, y, w, h);
2955+ g_gr->update();
2956
2957 p = ui_trackmouse(x, y);
2958 if (!p)
2959@@ -1189,9 +1243,32 @@
2960 }
2961
2962 /**
2963+ * Input callback function. Pass the mousewheel event to the currently modal
2964+ * panel.
2965+*/
2966+void Panel::ui_mousewheel(uint32_t which, int32_t x, int32_t y) {
2967+ if (!_g_allow_user_input) {
2968+ return;
2969+ }
2970+ if (!x && !y) {
2971+ return;
2972+ }
2973+ Panel* p = nullptr;
2974+ if (_g_mousein) {
2975+ p = _g_mousein;
2976+ } else {
2977+ p = _g_mousegrab ? _g_mousegrab : _modal;
2978+ }
2979+ if (p) {
2980+ p->do_mousewheel(which, x, y);
2981+ }
2982+}
2983+
2984+
2985+/**
2986 * Input callback function. Pass the key event to the currently modal panel
2987 */
2988-void Panel::ui_key(bool const down, SDL_keysym const code)
2989+void Panel::ui_key(bool const down, SDL_Keysym const code)
2990 {
2991 if (!_g_allow_user_input)
2992 return;
2993@@ -1199,14 +1276,25 @@
2994 _modal->do_key(down, code);
2995 }
2996
2997+
2998+/**
2999+ * Input callback function. Pass the textinput event to the currently modal panel
3000+ */
3001+void Panel::ui_textinput(const char * text) {
3002+ if (!_g_allow_user_input) {
3003+ return;
3004+ }
3005+ _modal->do_textinput(text);
3006+}
3007+
3008 /**
3009 * Draw the tooltip. Return true on success
3010 */
3011 bool Panel::draw_tooltip(RenderTarget & dst, const std::string & text)
3012 {
3013- if (text.empty())
3014+ if (text.empty()) {
3015 return false;
3016-
3017+ }
3018 std::string text_to_render = text;
3019 if (!is_richtext(text_to_render)) {
3020 text_to_render = as_tooltip(text);
3021@@ -1214,9 +1302,9 @@
3022
3023 static const uint32_t TIP_WIDTH_MAX = 360;
3024 const Image* rendered_text = g_fh1->render(text_to_render, TIP_WIDTH_MAX);
3025- if (!rendered_text)
3026+ if (!rendered_text) {
3027 return false;
3028-
3029+ }
3030 uint16_t tip_width = rendered_text->width() + 4;
3031 uint16_t tip_height = rendered_text->height() + 4;
3032
3033
3034=== modified file 'src/ui_basic/panel.h'
3035--- src/ui_basic/panel.h 2014-07-23 14:49:10 +0000
3036+++ src/ui_basic/panel.h 2014-11-02 20:06:40 +0000
3037@@ -74,6 +74,8 @@
3038 pf_layout_toplevel = 512,
3039 /// whether widget panels should be cached when possible
3040 pf_cache = 1024,
3041+ /// whether widget wants to receive unicode textinput messages
3042+ pf_textinput = 2048,
3043 }; // TODO(unknown): Turn this into separate bool flags
3044
3045 Panel
3046@@ -186,21 +188,23 @@
3047 virtual bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y);
3048 virtual bool handle_mousemove
3049 (uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
3050- virtual bool handle_key(bool down, SDL_keysym code);
3051+ virtual bool handle_mousewheel(uint32_t which, int32_t x, int32_t y);
3052+ virtual bool handle_key(bool down, SDL_Keysym);
3053+ virtual bool handle_textinput(const char* text);
3054 virtual bool handle_alt_drag(int32_t x, int32_t y);
3055 virtual bool handle_tooltip();
3056
3057 /// \returns whether a certain given is currently down.
3058 ///
3059 /// \note Never call this function from a keyboard event handler (a function
3060- /// that overrides bool handle_key(bool, SDL_keysym code)) to get the state
3061+ /// that overrides bool handle_key(bool, SDL_Keysym code)) to get the state
3062 /// of a modifier key. In that case code.mod must be used. It contains the
3063 /// state of the modifier keys at the time of the event. Unfortunately there
3064 /// is no information about modifier key states in mouse events (tracker
3065 /// item #1916453). That is "a huge oversight" in SDL 1.2 and a fix is
3066 /// promised in SDL 1.3:
3067 /// http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-March/064560.html
3068- bool get_key_state(SDLKey) const;
3069+ bool get_key_state(SDL_Scancode) const;
3070
3071 void set_handle_mouse(bool yes);
3072 bool get_handle_mouse() const {return _flags & pf_handle_mouse;}
3073@@ -212,7 +216,7 @@
3074 assert(get_can_focus());
3075 return (_parent->_focus == this);
3076 }
3077- virtual void focus();
3078+ virtual void focus(bool topcaller = true);
3079
3080 void set_think(bool yes);
3081 bool get_think() const {return _flags & pf_think;}
3082@@ -231,6 +235,11 @@
3083 void set_tooltip(const std::string& text) {_tooltip = text;}
3084 const std::string& tooltip() const {return _tooltip;}
3085
3086+ void set_handle_textinput(bool on) {
3087+ on ? _flags |= pf_textinput : _flags &= ~pf_textinput;
3088+ }
3089+ bool get_handle_textinput() const {return _flags & pf_textinput;}
3090+
3091 ///\return the current set UI font
3092 std::string ui_fn();
3093
3094@@ -263,7 +272,9 @@
3095 bool do_mouserelease(const uint8_t btn, int32_t x, int32_t y);
3096 bool do_mousemove
3097 (const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
3098- bool do_key(bool down, SDL_keysym code);
3099+ bool do_mousewheel(uint32_t which, int32_t x, int32_t y);
3100+ bool do_key(bool down, SDL_Keysym code);
3101+ bool do_textinput(const char* text);
3102 bool do_tooltip();
3103
3104 static Panel * ui_trackmouse(int32_t & x, int32_t & y);
3105@@ -271,8 +282,9 @@
3106 static void ui_mouserelease(const uint8_t button, int32_t x, int32_t y);
3107 static void ui_mousemove
3108 (const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
3109- static void ui_key(bool down, SDL_keysym code);
3110-
3111+ static void ui_mousewheel(uint32_t which, int32_t x, int32_t y);
3112+ static void ui_key(bool down, SDL_Keysym code);
3113+ static void ui_textinput(const char* text);
3114
3115 Panel * _parent;
3116 Panel * _next, * _prev;
3117
3118=== modified file 'src/ui_basic/progresswindow.cc'
3119--- src/ui_basic/progresswindow.cc 2014-09-20 09:37:47 +0000
3120+++ src/ui_basic/progresswindow.cc 2014-11-02 20:06:40 +0000
3121@@ -117,7 +117,7 @@
3122 UI::TextStyle ts(UI::TextStyle::ui_small());
3123 ts.fg = PROGRESS_FONT_COLOR_FG;
3124 UI::g_fh->draw_text(rt, ts, m_label_center, description, Align_Center);
3125- g_gr->update_rectangle(m_label_rectangle);
3126+ g_gr->update();
3127
3128 #ifdef _WIN32
3129 // Pump events to prevent "not responding" on windows
3130@@ -131,7 +131,7 @@
3131 for (IProgressVisualization * visualization : m_visualizations) {
3132 visualization->update(repaint); // let visualizations do their work
3133 }
3134- g_gr->refresh(false);
3135+ g_gr->refresh();
3136 }
3137
3138 /**
3139
3140=== modified file 'src/ui_basic/scrollbar.cc'
3141--- src/ui_basic/scrollbar.cc 2014-07-14 10:45:44 +0000
3142+++ src/ui_basic/scrollbar.cc 2014-11-02 20:06:40 +0000
3143@@ -391,6 +391,16 @@
3144 }
3145
3146
3147+bool Scrollbar::handle_mousewheel(uint32_t, int32_t, int32_t y) {
3148+ if (y < 0) {
3149+ action(Plus);
3150+ } else {
3151+ action(Minus);
3152+ }
3153+ return true;
3154+}
3155+
3156+
3157 bool Scrollbar::handle_mousepress(const uint8_t btn, int32_t x, int32_t y) {
3158 bool result = false;
3159
3160@@ -410,15 +420,6 @@
3161 result = true;
3162 break;
3163
3164- case SDL_BUTTON_WHEELUP:
3165- action(Minus);
3166- result = true;
3167- break;
3168-
3169- case SDL_BUTTON_WHEELDOWN:
3170- action(Plus);
3171- result = true;
3172- break;
3173 default:
3174 break;
3175 }
3176@@ -437,13 +438,6 @@
3177 result = true;
3178 break;
3179
3180- case SDL_BUTTON_WHEELUP:
3181- result = true;
3182- break;
3183-
3184- case SDL_BUTTON_WHEELDOWN:
3185- result = true;
3186- break;
3187 default:
3188 break;
3189 }
3190
3191=== modified file 'src/ui_basic/scrollbar.h'
3192--- src/ui_basic/scrollbar.h 2014-07-14 10:45:44 +0000
3193+++ src/ui_basic/scrollbar.h 2014-11-02 20:06:40 +0000
3194@@ -62,7 +62,8 @@
3195 uint32_t get_pagesize() const {return m_pagesize;}
3196 uint32_t get_scrollpos() const {return m_pos;}
3197
3198- bool handle_mousepress (uint8_t btn, int32_t x, int32_t y) override;
3199+ bool handle_mousepress(uint8_t btn, int32_t x, int32_t y) override;
3200+ bool handle_mousewheel(uint32_t, int32_t, int32_t y) override;
3201
3202 void set_force_draw(bool const t) {m_force_draw = t;}
3203
3204
3205=== modified file 'src/ui_basic/table.cc'
3206--- src/ui_basic/table.cc 2014-09-30 19:36:00 +0000
3207+++ src/ui_basic/table.cc 2014-11-02 20:06:40 +0000
3208@@ -324,17 +324,17 @@
3209 /**
3210 * handle key presses
3211 */
3212-bool Table<void *>::handle_key(bool down, SDL_keysym code)
3213+bool Table<void *>::handle_key(bool down, SDL_Keysym code)
3214 {
3215 if (down) {
3216 switch (code.sym) {
3217- case SDLK_UP:
3218- case SDLK_KP8:
3219+ case SDL_SCANCODE_UP:
3220+ case SDL_SCANCODE_KP_8:
3221 move_selection(-1);
3222 return true;
3223
3224- case SDLK_DOWN:
3225- case SDLK_KP2:
3226+ case SDL_SCANCODE_DOWN:
3227+ case SDL_SCANCODE_KP_2:
3228 move_selection(1);
3229 return true;
3230
3231@@ -346,6 +346,11 @@
3232 return UI::Panel::handle_key(down, code);
3233 }
3234
3235+
3236+bool Table<void *>::handle_mousewheel(uint32_t which, int32_t x, int32_t y) {
3237+ return m_scrollbar->handle_mousewheel(which, x, y);
3238+}
3239+
3240 /**
3241 * Handle mouse presses: select the appropriate entry
3242 */
3243@@ -356,9 +361,6 @@
3244 focus();
3245
3246 switch (btn) {
3247- case SDL_BUTTON_WHEELDOWN:
3248- case SDL_BUTTON_WHEELUP:
3249- return m_scrollbar ? m_scrollbar->handle_mousepress(btn, 0, y) : false;
3250 case SDL_BUTTON_LEFT: {
3251 int32_t const time = WLApplication::get()->get_time();
3252
3253
3254=== modified file 'src/ui_basic/table.h'
3255--- src/ui_basic/table.h 2014-09-30 19:36:00 +0000
3256+++ src/ui_basic/table.h 2014-11-02 20:06:40 +0000
3257@@ -107,7 +107,8 @@
3258 void draw(RenderTarget &);
3259 bool handle_mousepress (uint8_t btn, int32_t x, int32_t y);
3260 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y);
3261- virtual bool handle_key(bool down, SDL_keysym code);
3262+ bool handle_mousewheel(uint32_t which, int32_t x, int32_t y);
3263+ virtual bool handle_key(bool down, SDL_Keysym code);
3264 };
3265
3266 template <> class Table<void *> : public Panel {
3267@@ -243,7 +244,8 @@
3268 void draw(RenderTarget &) override;
3269 bool handle_mousepress (uint8_t btn, int32_t x, int32_t y) override;
3270 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
3271- bool handle_key(bool down, SDL_keysym code) override;
3272+ bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
3273+ bool handle_key(bool down, SDL_Keysym code) override;
3274
3275 private:
3276 bool default_compare_checkbox(uint32_t column, uint32_t a, uint32_t b);
3277
3278=== modified file 'src/ui_basic/window.cc'
3279--- src/ui_basic/window.cc 2014-07-25 22:17:48 +0000
3280+++ src/ui_basic/window.cc 2014-11-02 20:06:40 +0000
3281@@ -19,7 +19,7 @@
3282
3283 #include "ui_basic/window.h"
3284
3285-#include <SDL_keysym.h>
3286+#include <SDL_keycode.h>
3287
3288 #include "base/log.h"
3289 #include "graphic/font.h"
3290@@ -436,7 +436,7 @@
3291 // needs is the key state at the time the mouse was clicked. See the
3292 // usage comment for get_key_state.
3293 if
3294- (((get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL))
3295+ (((get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL))
3296 &&
3297 btn == SDL_BUTTON_LEFT)
3298 ||
3299
3300=== modified file 'src/ui_fsmenu/intro.cc'
3301--- src/ui_fsmenu/intro.cc 2014-09-10 14:08:25 +0000
3302+++ src/ui_fsmenu/intro.cc 2014-11-02 20:06:40 +0000
3303@@ -45,7 +45,7 @@
3304 return true;
3305 }
3306
3307-bool FullscreenMenuIntro::handle_key(bool const down, SDL_keysym const code)
3308+bool FullscreenMenuIntro::handle_key(bool const down, SDL_Keysym const code)
3309 {
3310 if (down && code.sym == SDLK_ESCAPE)
3311 end_modal(0);
3312
3313=== modified file 'src/ui_fsmenu/intro.h'
3314--- src/ui_fsmenu/intro.h 2014-09-10 14:08:25 +0000
3315+++ src/ui_fsmenu/intro.h 2014-11-02 20:06:40 +0000
3316@@ -34,7 +34,7 @@
3317 protected:
3318 bool handle_mousepress (uint8_t btn, int32_t x, int32_t y) override;
3319 bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
3320- bool handle_key(bool down, SDL_keysym) override;
3321+ bool handle_key(bool down, SDL_Keysym) override;
3322 private:
3323 UI::Textarea m_message;
3324 };
3325
3326=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
3327--- src/ui_fsmenu/load_map_or_game.cc 2014-10-13 09:50:55 +0000
3328+++ src/ui_fsmenu/load_map_or_game.cc 2014-11-02 20:06:40 +0000
3329@@ -67,14 +67,14 @@
3330 m_table(this, m_tablex, m_tabley, m_tablew, m_tableh, sort_descending)
3331 {}
3332
3333-bool FullscreenMenuLoadMapOrGame::handle_key(bool down, SDL_keysym code) {
3334+bool FullscreenMenuLoadMapOrGame::handle_key(bool down, SDL_Keysym code) {
3335
3336 if (!down)
3337 return false;
3338
3339 switch (code.sym)
3340 {
3341- case SDLK_KP_ENTER:
3342+ case SDL_SCANCODE_KP_ENTER:
3343 case SDLK_RETURN:
3344 clicked_ok();
3345 return true;
3346
3347=== modified file 'src/ui_fsmenu/load_map_or_game.h'
3348--- src/ui_fsmenu/load_map_or_game.h 2014-10-29 06:00:52 +0000
3349+++ src/ui_fsmenu/load_map_or_game.h 2014-11-02 20:06:40 +0000
3350@@ -75,7 +75,7 @@
3351 struct FullscreenMenuLoadMapOrGame : public FullscreenMenuBase {
3352 FullscreenMenuLoadMapOrGame(bool sortdesc = false);
3353
3354- bool handle_key(bool down, SDL_keysym code) override;
3355+ bool handle_key(bool down, SDL_Keysym code) override;
3356
3357 protected:
3358 virtual void clicked_ok() {end_modal(1);}
3359
3360=== modified file 'src/ui_fsmenu/loadgame.cc'
3361--- src/ui_fsmenu/loadgame.cc 2014-10-28 08:16:53 +0000
3362+++ src/ui_fsmenu/loadgame.cc 2014-11-02 20:06:40 +0000
3363@@ -532,14 +532,14 @@
3364 set_has_selection();
3365 }
3366
3367-bool FullscreenMenuLoadGame::handle_key(bool down, SDL_keysym code)
3368+bool FullscreenMenuLoadGame::handle_key(bool down, SDL_Keysym code)
3369 {
3370 if (!down)
3371 return false;
3372
3373 switch (code.sym)
3374 {
3375- case SDLK_KP_PERIOD:
3376+ case SDL_SCANCODE_KP_PERIOD:
3377 if (code.mod & KMOD_NUM)
3378 break;
3379 /* no break */
3380
3381=== modified file 'src/ui_fsmenu/loadgame.h'
3382--- src/ui_fsmenu/loadgame.h 2014-10-17 08:27:50 +0000
3383+++ src/ui_fsmenu/loadgame.h 2014-11-02 20:06:40 +0000
3384@@ -76,7 +76,7 @@
3385
3386 void think();
3387
3388- bool handle_key(bool down, SDL_keysym code) override;
3389+ bool handle_key(bool down, SDL_Keysym code) override;
3390
3391 protected:
3392 void clicked_ok() override;
3393
3394=== modified file 'src/ui_fsmenu/options.cc'
3395--- src/ui_fsmenu/options.cc 2014-10-27 10:31:04 +0000
3396+++ src/ui_fsmenu/options.cc 2014-11-02 20:06:40 +0000
3397@@ -335,24 +335,18 @@
3398 m_snap_win_overlap_only .set_state(opt.snap_win_overlap_only);
3399 m_dock_windows_to_edges .set_state(opt.dock_windows_to_edges);
3400
3401- // GRAPHIC_TODO(unknown): this shouldn't be here List all resolutions
3402- // take a copy to not change real video info structure
3403- SDL_PixelFormat fmt = *SDL_GetVideoInfo()->vfmt;
3404- fmt.BitsPerPixel = 32;
3405- for
3406- (const SDL_Rect * const * modes = SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN);
3407- modes && *modes;
3408- ++modes)
3409- {
3410- const SDL_Rect & mode = **modes;
3411- if (800 <= mode.w && 600 <= mode.h)
3412- {
3413- const ScreenResolution this_res = {mode.w, mode.h};
3414- if
3415- (m_resolutions.empty()
3416+ for (int modes = 0; modes < SDL_GetNumDisplayModes(0); ++modes) {
3417+ SDL_DisplayMode mode;
3418+ SDL_GetDisplayMode(0, modes, & mode);
3419+ if (800 <= mode.w && 600 <= mode.h &&
3420+ (SDL_BITSPERPIXEL(mode.format) == 32 ||
3421+ SDL_BITSPERPIXEL(mode.format) == 24)) {
3422+ ScreenResolution this_res = {
3423+ mode.w, mode.h, static_cast<int32_t>(SDL_BITSPERPIXEL(mode.format))};
3424+ if (this_res.depth == 24) this_res.depth = 32;
3425+ if (m_resolutions.empty()
3426 || this_res.xres != m_resolutions.rbegin()->xres
3427- || this_res.yres != m_resolutions.rbegin()->yres)
3428- {
3429+ || this_res.yres != m_resolutions.rbegin()->yres) {
3430 m_resolutions.push_back(this_res);
3431 }
3432 }
3433@@ -391,6 +385,8 @@
3434 nullptr, "en" == opt.language);
3435
3436 add_languages_to_list(&m_language_list, opt.language);
3437+
3438+ m_language_list.focus();
3439 }
3440
3441 void FullscreenMenuOptions::update_sb_autosave_unit() {
3442@@ -409,11 +405,11 @@
3443 }
3444 }
3445
3446-bool FullscreenMenuOptions::handle_key(bool down, SDL_keysym code)
3447+bool FullscreenMenuOptions::handle_key(bool down, SDL_Keysym code)
3448 {
3449 if (down) {
3450 switch (code.sym) {
3451- case SDLK_KP_ENTER:
3452+ case SDL_SCANCODE_KP_ENTER:
3453 case SDLK_RETURN:
3454 end_modal(static_cast<int32_t>(om_ok));
3455 return true;
3456@@ -618,6 +614,7 @@
3457 did_select_a_font |= cmpbool;
3458 m_ui_font_list.add
3459 ("Widelands", UI_FONT_NAME_WIDELANDS, nullptr, cmpbool);
3460+ m_ui_font_list.focus();
3461
3462 // Fill with all left *.ttf files we find in fonts
3463 FilenameSet files =
3464@@ -648,11 +645,11 @@
3465 }
3466 }
3467
3468-bool FullscreenMenuAdvancedOptions::handle_key(bool down, SDL_keysym code)
3469+bool FullscreenMenuAdvancedOptions::handle_key(bool down, SDL_Keysym code)
3470 {
3471 if (down) {
3472 switch (code.sym) {
3473- case SDLK_KP_ENTER:
3474+ case SDL_SCANCODE_KP_ENTER:
3475 case SDLK_RETURN:
3476 end_modal(static_cast<int32_t>(om_ok));
3477 return true;
3478
3479=== modified file 'src/ui_fsmenu/options.h'
3480--- src/ui_fsmenu/options.h 2014-09-27 11:23:37 +0000
3481+++ src/ui_fsmenu/options.h 2014-11-02 20:06:40 +0000
3482@@ -90,7 +90,7 @@
3483 };
3484
3485 /// Handle keypresses
3486- bool handle_key(bool down, SDL_keysym code) override;
3487+ bool handle_key(bool down, SDL_Keysym code) override;
3488
3489 private:
3490 uint32_t const m_vbutw;
3491@@ -147,6 +147,7 @@
3492 public:
3493 int32_t xres;
3494 int32_t yres;
3495+ int32_t depth;
3496 };
3497
3498 /// All supported screen resolutions.
3499@@ -167,7 +168,7 @@
3500 };
3501
3502 /// Handle keypresses
3503- bool handle_key(bool down, SDL_keysym code) override;
3504+ bool handle_key(bool down, SDL_Keysym code) override;
3505
3506 private:
3507 void update_sb_dis_panel_unit();
3508
3509=== modified file 'src/wlapplication.cc'
3510--- src/wlapplication.cc 2014-10-29 08:15:50 +0000
3511+++ src/wlapplication.cc 2014-11-02 20:06:40 +0000
3512@@ -489,10 +489,6 @@
3513 g_sound_handler.change_music();
3514 break;
3515
3516- case SDL_VIDEOEXPOSE:
3517- // log ("SDL Video Window expose event: %i\n", ev.expose.type);
3518- g_gr->update_fullscreen();
3519- break;
3520 default:
3521 break;
3522 }
3523@@ -510,15 +506,15 @@
3524 case SDL_KEYDOWN:
3525 case SDL_KEYUP:
3526 if
3527- (ev.key.keysym.sym == SDLK_F10 &&
3528- (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)))
3529+ (ev.key.keysym.sym == SDL_SCANCODE_F10 &&
3530+ (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)))
3531 {
3532 // get out of here quick
3533 if (ev.type == SDL_KEYDOWN)
3534 m_should_die = true;
3535 break;
3536 }
3537- if (ev.key.keysym.sym == SDLK_F11) { // take screenshot
3538+ if (ev.key.keysym.sym == SDL_SCANCODE_F11) { // take screenshot
3539 if (ev.type == SDL_KEYDOWN)
3540 {
3541 if (g_fs->disk_space() < MINIMUM_DISK_SPACE) {
3542@@ -544,11 +540,20 @@
3543 }
3544 break;
3545
3546+ case SDL_TEXTINPUT:
3547+ if (cb && cb->textinput) {
3548+ cb->textinput(ev.text.text);
3549+ }
3550+ break;
3551 case SDL_MOUSEBUTTONDOWN:
3552 case SDL_MOUSEBUTTONUP:
3553 _handle_mousebutton(ev, cb);
3554 break;
3555-
3556+ case SDL_MOUSEWHEEL:
3557+ if (cb && cb->mouse_wheel) {
3558+ cb->mouse_wheel(ev.wheel.which, ev.wheel.x, ev.wheel.y);
3559+ }
3560+ break;
3561 case SDL_MOUSEMOTION:
3562 m_mouse_position = Point(ev.motion.x, ev.motion.y);
3563
3564@@ -558,7 +563,6 @@
3565 ev.motion.x, ev.motion.y,
3566 ev.motion.xrel, ev.motion.yrel);
3567 break;
3568-
3569 case SDL_QUIT:
3570 m_should_die = true;
3571 break;
3572@@ -594,7 +598,7 @@
3573 // mouse button.
3574 if
3575 (ev.button.button == SDL_BUTTON_MIDDLE &&
3576- (get_key_state(SDLK_LALT) || get_key_state(SDLK_RALT)))
3577+ (get_key_state(SDL_SCANCODE_LALT) || get_key_state(SDL_SCANCODE_RALT)))
3578 {
3579 ev.button.button = SDL_BUTTON_LEFT;
3580 m_faking_middle_mouse_button = true;
3581@@ -627,8 +631,8 @@
3582
3583 /// Instantaneously move the mouse cursor without creating a motion event.
3584 ///
3585-/// SDL_WarpMouse() *will* create a mousemotion event, which we do not want. As
3586-/// a workaround, we store the delta in m_mouse_compensate_warp and use that to
3587+/// SDL_WarpMouseInWindow() *will* create a mousemotion event, which we do not want.
3588+/// As a workaround, we store the delta in m_mouse_compensate_warp and use that to
3589 /// eliminate the motion event in poll_event()
3590 ///
3591 /// \param position The new mouse position
3592@@ -640,7 +644,10 @@
3593 SDL_GetMouseState(&cur_position.x, &cur_position.y);
3594 if (cur_position != position) {
3595 m_mouse_compensate_warp += cur_position - position;
3596- SDL_WarpMouse(position.x, position.y);
3597+ SDL_Window* sdl_window = g_gr->get_sdlwindow();
3598+ if (sdl_window) {
3599+ SDL_WarpMouseInWindow(sdl_window, position.x, position.y);
3600+ }
3601 }
3602 }
3603
3604@@ -655,10 +662,18 @@
3605 */
3606 void WLApplication::set_input_grab(bool grab)
3607 {
3608+ if (!g_gr) {
3609+ return;
3610+ }
3611+ SDL_Window * sdl_window = g_gr->get_sdlwindow();
3612 if (grab) {
3613- SDL_WM_GrabInput(SDL_GRAB_ON);
3614+ if (sdl_window) {
3615+ SDL_SetWindowGrab(sdl_window, SDL_TRUE);
3616+ }
3617 } else {
3618- SDL_WM_GrabInput(SDL_GRAB_OFF);
3619+ if (sdl_window) {
3620+ SDL_SetWindowGrab(sdl_window, SDL_FALSE);
3621+ }
3622 warp_mouse(m_mouse_position); //TODO(unknown): is this redundant?
3623 }
3624 }
3625@@ -700,6 +715,8 @@
3626 s.get_int("yres", DEFAULT_RESOLUTION_H),
3627 s.get_bool("fullscreen", false),
3628 s.get_bool("opengl", true));
3629+ // does only work with a window
3630+ set_input_grab(s.get_bool("inputgrab", false));
3631 }
3632
3633 /**
3634@@ -715,7 +732,6 @@
3635 //then parse the commandline - overwrites conffile settings
3636 handle_commandline_parameters();
3637
3638- set_input_grab(s.get_bool("inputgrab", false));
3639 set_mouse_swap(s.get_bool("swapmouse", false));
3640
3641 // KLUDGE!
3642@@ -827,50 +843,12 @@
3643 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
3644 #endif
3645
3646- //try all available video drivers till we find one that matches
3647- std::vector<std::string> videomode;
3648- int result = -1;
3649-
3650- //add default video mode
3651-#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
3652- videomode.push_back("x11");
3653-#endif
3654-#ifdef _WIN32
3655- videomode.push_back("windib");
3656-#endif
3657-#ifdef __APPLE__
3658- videomode.push_back("Quartz");
3659-#endif
3660- //if a video mode is given on the command line, add that one first
3661- {
3662- const char * videodrv;
3663- videodrv = getenv("SDL_VIDEODRIVER");
3664- if (videodrv) {
3665- log("Also adding video driver %s\n", videodrv);
3666- videomode.push_back(videodrv);
3667- }
3668- }
3669- char videodrvused[26];
3670- strcpy(videodrvused, "SDL_VIDEODRIVER=\0");
3671- wout << videodrvused << "&" << std::endl;
3672- for (int i = videomode.size() - 1; result == -1 && i >= 0; --i) {
3673- strcpy(videodrvused + 16, videomode[i].c_str());
3674- videodrvused[16 + videomode[i].size()] = '\0';
3675- putenv(videodrvused);
3676- log
3677- ("Graphics: Trying Video driver: %i %s %s\n",
3678- i, videomode[i].c_str(), videodrvused);
3679- result = SDL_Init(sdl_flags);
3680- }
3681-
3682- if (result == -1)
3683+ if (SDL_Init(sdl_flags) == -1)
3684 throw wexception
3685 ("Failed to initialize SDL, no valid video driver: %s",
3686 SDL_GetError());
3687
3688 SDL_ShowCursor(SDL_DISABLE);
3689- SDL_EnableUNICODE(1);
3690- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
3691
3692 refresh_graphics();
3693
3694@@ -891,8 +869,7 @@
3695 << std::endl;
3696
3697 init_graphics(0, 0, false, false);
3698- SDL_QuitSubSystem
3699- (SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_CDROM|SDL_INIT_JOYSTICK);
3700+ SDL_QuitSubSystem(SDL_INIT_TIMER|SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
3701
3702 #ifndef _WIN32
3703 // SOUND can lock up with buggy SDL/drivers. we try to do the right thing
3704
3705=== modified file 'src/wlapplication.h'
3706--- src/wlapplication.h 2014-10-28 12:50:28 +0000
3707+++ src/wlapplication.h 2014-11-02 20:06:40 +0000
3708@@ -58,7 +58,9 @@
3709 int32_t x, int32_t y); // The coordinates of the mouse at release time.
3710 void (*mouse_move)
3711 (const uint8_t state, int32_t x, int32_t y, int32_t xdiff, int32_t ydiff);
3712- void (*key) (bool down, SDL_keysym code);
3713+ void (*key) (bool down, SDL_Keysym code);
3714+ void (*textinput) (const char * text);
3715+ void (*mouse_wheel) (uint32_t which, int32_t x, int32_t y);
3716 };
3717
3718 /// You know main functions, of course. This is the main struct.
3719@@ -143,7 +145,7 @@
3720
3721 /// Get the state of the current KeyBoard Button
3722 /// \warning This function doesn't check for dumbness
3723- bool get_key_state(SDLKey const key) const {return SDL_GetKeyState(nullptr)[key];}
3724+ bool get_key_state(SDL_Scancode const key) const {return SDL_GetKeyboardState(nullptr)[key];}
3725
3726 //@{
3727 void warp_mouse(Point);
3728
3729=== modified file 'src/wui/CMakeLists.txt'
3730--- src/wui/CMakeLists.txt 2014-07-16 08:23:42 +0000
3731+++ src/wui/CMakeLists.txt 2014-11-02 20:06:40 +0000
3732@@ -127,7 +127,7 @@
3733 waresqueuedisplay.h
3734 watchwindow.cc
3735 watchwindow.h
3736- USES_SDL
3737+ USES_SDL2
3738 DEPENDS
3739 base_deprecated
3740 base_exceptions
3741
3742=== modified file 'src/wui/actionconfirm.cc'
3743--- src/wui/actionconfirm.cc 2014-10-27 08:06:06 +0000
3744+++ src/wui/actionconfirm.cc 2014-11-02 20:06:40 +0000
3745@@ -265,7 +265,7 @@
3746 (building->get_playercaps() & Widelands::Building::PCap_Bulldoze))
3747 {
3748 game.send_player_bulldoze
3749- (*todestroy, get_key_state(SDLK_LCTRL) << get_key_state(SDLK_RCTRL));
3750+ (*todestroy, get_key_state(SDL_SCANCODE_LCTRL) << get_key_state(SDL_SCANCODE_RCTRL));
3751 iaplayer().need_complete_redraw();
3752 }
3753
3754
3755=== modified file 'src/wui/building_statistics_menu.cc'
3756--- src/wui/building_statistics_menu.cc 2014-10-19 12:15:46 +0000
3757+++ src/wui/building_statistics_menu.cc 2014-11-02 20:06:40 +0000
3758@@ -118,6 +118,7 @@
3759 (Columns::Size,
3760 boost::bind
3761 (&BuildingStatisticsMenu::compare_building_size, this, _1, _2));
3762+ m_table.focus();
3763
3764 // toggle when to run button
3765 m_progbar.set_total(100);
3766
3767=== modified file 'src/wui/buildingwindow.cc'
3768--- src/wui/buildingwindow.cc 2014-10-17 09:18:58 +0000
3769+++ src/wui/buildingwindow.cc 2014-11-02 20:06:40 +0000
3770@@ -373,7 +373,7 @@
3771 */
3772 void BuildingWindow::act_bulldoze()
3773 {
3774- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
3775+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
3776 if (m_building.get_playercaps() & Widelands::Building::PCap_Bulldoze)
3777 igbase().game().send_player_bulldoze(m_building);
3778 }
3779@@ -389,7 +389,7 @@
3780 */
3781 void BuildingWindow::act_dismantle()
3782 {
3783- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
3784+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
3785 if (m_building.get_playercaps() & Widelands::Building::PCap_Dismantle)
3786 igbase().game().send_player_dismantle(m_building);
3787 }
3788@@ -432,7 +432,7 @@
3789 */
3790 void BuildingWindow::act_enhance(Widelands::BuildingIndex id)
3791 {
3792- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
3793+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
3794 if (m_building.get_playercaps() & Widelands::Building::PCap_Enhancable)
3795 igbase().game().send_player_enhance_building(m_building, id);
3796 }
3797
3798=== modified file 'src/wui/encyclopedia_window.cc'
3799--- src/wui/encyclopedia_window.cc 2014-10-27 10:31:04 +0000
3800+++ src/wui/encyclopedia_window.cc 2014-11-02 20:06:40 +0000
3801@@ -77,6 +77,7 @@
3802 /** TRANSLATORS: Column title in the Tribal Wares Encyclopedia */
3803 (wareColumnWidth, ngettext("Consumed Ware Type", "Consumed Ware Types", 0));
3804 condTable.add_column (quantityColumnWidth, _("Quantity"));
3805+ condTable.focus();
3806
3807 fill_wares();
3808
3809
3810=== modified file 'src/wui/fieldaction.cc'
3811--- src/wui/fieldaction.cc 2014-09-20 09:37:47 +0000
3812+++ src/wui/fieldaction.cc 2014-11-02 20:06:40 +0000
3813@@ -737,9 +737,9 @@
3814 if (upcast(Widelands::Flag, flag, m_node.field->get_immovable())) {
3815 if (Building * const building = flag->get_building()) {
3816 if (building->get_playercaps() & Building::PCap_Bulldoze) {
3817- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
3818+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
3819 ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
3820- (*flag, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
3821+ (*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
3822 }
3823 else {
3824 show_bulldoze_confirm
3825@@ -750,7 +750,7 @@
3826 }
3827 } else {
3828 ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
3829- (*flag, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
3830+ (*flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
3831 ibase().need_complete_redraw();
3832 }
3833 }
3834@@ -795,7 +795,7 @@
3835 Widelands::EditorGameBase & egbase = ibase().egbase();
3836 if (upcast(Widelands::Road, road, egbase.map().get_immovable(m_node)))
3837 ref_cast<Game, EditorGameBase>(egbase).send_player_bulldoze
3838- (*road, get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL));
3839+ (*road, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
3840 ibase().need_complete_redraw();
3841 okdialog();
3842 }
3843
3844=== modified file 'src/wui/game_message_menu.cc'
3845--- src/wui/game_message_menu.cc 2014-10-11 10:04:45 +0000
3846+++ src/wui/game_message_menu.cc 2014-11-02 20:06:40 +0000
3847@@ -57,6 +57,7 @@
3848 list->add_column (60, _("Status"), "", UI::Align_HCenter);
3849 list->add_column(330, _("Title"));
3850 list->add_column(120, _("Time sent"));
3851+ list->focus();
3852
3853 UI::Button * clearselectionbtn =
3854 new UI::Button
3855@@ -243,7 +244,7 @@
3856 /**
3857 * Handle message menu hotkeys.
3858 */
3859-bool GameMessageMenu::handle_key(bool down, SDL_keysym code)
3860+bool GameMessageMenu::handle_key(bool down, SDL_Keysym code)
3861 {
3862 if (down) {
3863 switch (code.sym) {
3864@@ -252,7 +253,7 @@
3865 center_view();
3866 return true;
3867
3868- case SDLK_KP_PERIOD:
3869+ case SDL_SCANCODE_KP_PERIOD:
3870 if (code.mod & KMOD_NUM)
3871 break;
3872 /* no break */
3873
3874=== modified file 'src/wui/game_message_menu.h'
3875--- src/wui/game_message_menu.h 2014-09-10 14:48:40 +0000
3876+++ src/wui/game_message_menu.h 2014-11-02 20:06:40 +0000
3877@@ -45,7 +45,7 @@
3878
3879 enum Mode {Inbox, Archive};
3880 void think() override;
3881- bool handle_key(bool down, SDL_keysym code) override;
3882+ bool handle_key(bool down, SDL_Keysym code) override;
3883
3884 private:
3885 enum Cols {ColSelect, ColStatus, ColTitle, ColTimeSent};
3886
3887=== modified file 'src/wui/game_options_menu.cc'
3888--- src/wui/game_options_menu.cc 2014-10-13 19:32:08 +0000
3889+++ src/wui/game_options_menu.cc 2014-11-02 20:06:40 +0000
3890@@ -182,7 +182,7 @@
3891 }
3892
3893 void GameOptionsMenu::clicked_exit_game() {
3894- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
3895+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
3896 m_gb.end_modal(0);
3897 }
3898 else {
3899
3900=== modified file 'src/wui/game_tips.cc'
3901--- src/wui/game_tips.cc 2014-07-14 10:45:44 +0000
3902+++ src/wui/game_tips.cc 2014-11-02 20:06:40 +0000
3903@@ -121,5 +121,5 @@
3904 const Image* rendered_text = UI::g_fh1->render(as_game_tip(m_tips[index].text), tips_area.w);
3905 rt.blit(center - Point(rendered_text->width() / 2, rendered_text->height() / 2), rendered_text);
3906
3907- g_gr->update_rectangle(tips_area);
3908+ g_gr->update();
3909 }
3910
3911=== modified file 'src/wui/interactive_base.cc'
3912--- src/wui/interactive_base.cc 2014-10-27 10:14:10 +0000
3913+++ src/wui/interactive_base.cc 2014-11-02 20:06:40 +0000
3914@@ -366,14 +366,22 @@
3915 const uint32_t scrollval = 10;
3916
3917 if (keyboard_free() && Panel::allow_user_input()) {
3918- if (get_key_state(SDLK_UP) || (get_key_state(SDLK_KP8) && (SDL_GetModState() ^ KMOD_NUM)))
3919+ if (get_key_state(SDL_SCANCODE_UP) ||
3920+ (get_key_state(SDL_SCANCODE_KP_8) && (SDL_GetModState() ^ KMOD_NUM))) {
3921 set_rel_viewpoint(Point(0, -scrollval), false);
3922- if (get_key_state(SDLK_DOWN) || (get_key_state(SDLK_KP2) && (SDL_GetModState() ^ KMOD_NUM)))
3923+ }
3924+ if (get_key_state(SDL_SCANCODE_DOWN) ||
3925+ (get_key_state(SDL_SCANCODE_KP_2) && (SDL_GetModState() ^ KMOD_NUM))) {
3926 set_rel_viewpoint(Point(0, scrollval), false);
3927- if (get_key_state(SDLK_LEFT) || (get_key_state(SDLK_KP4) && (SDL_GetModState() ^ KMOD_NUM)))
3928+ }
3929+ if (get_key_state(SDL_SCANCODE_LEFT) ||
3930+ (get_key_state(SDL_SCANCODE_KP_4) && (SDL_GetModState() ^ KMOD_NUM))) {
3931 set_rel_viewpoint(Point(-scrollval, 0), false);
3932- if (get_key_state(SDLK_RIGHT) || (get_key_state(SDLK_KP6) && (SDL_GetModState() ^ KMOD_NUM)))
3933+ }
3934+ if (get_key_state(SDL_SCANCODE_RIGHT) ||
3935+ (get_key_state(SDL_SCANCODE_KP_6) && (SDL_GetModState() ^ KMOD_NUM))) {
3936 set_rel_viewpoint(Point (scrollval, 0), false);
3937+ }
3938 }
3939
3940 egbase().think(); // Call game logic here. The game advances.
3941@@ -386,7 +394,7 @@
3942
3943 // The entire screen needs to be redrawn (unit movement, tile animation,
3944 // etc...)
3945- g_gr->update_fullscreen();
3946+ g_gr->update();
3947
3948 update_speedlabel();
3949
3950@@ -656,7 +664,7 @@
3951
3952 if
3953 (allow_user_input() &&
3954- (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)))
3955+ (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)))
3956 {
3957 // place flags
3958 const Map & map = egbase().map();
3959@@ -667,7 +675,7 @@
3960 std::vector<Coords>::const_iterator const last =
3961 c_vector.end () - 2;
3962
3963- if (get_key_state(SDLK_LSHIFT) || get_key_state(SDLK_RSHIFT)) {
3964+ if (get_key_state(SDL_SCANCODE_LSHIFT) || get_key_state(SDL_SCANCODE_RSHIFT)) {
3965 for // start to end
3966 (std::vector<Coords>::const_iterator it = first;
3967 it <= last;
3968@@ -906,13 +914,13 @@
3969 }
3970
3971
3972-bool InteractiveBase::handle_key(bool const down, SDL_keysym const code)
3973+bool InteractiveBase::handle_key(bool const down, SDL_Keysym const code)
3974 {
3975 if (m->quicknavigation->handle_key(down, code))
3976 return true;
3977
3978 switch (code.sym) {
3979- case SDLK_KP9:
3980+ case SDL_SCANCODE_KP_9:
3981 if (code.mod & KMOD_NUM)
3982 break;
3983 /* no break */
3984@@ -933,7 +941,7 @@
3985 ctrl->toggle_paused();
3986 return true;
3987
3988- case SDLK_KP3:
3989+ case SDL_SCANCODE_KP_3:
3990 if (code.mod & KMOD_NUM)
3991 break;
3992 /* no break */
3993@@ -949,7 +957,7 @@
3994 }
3995 return true;
3996 #ifndef NDEBUG // only in debug builds
3997- case SDLK_F6:
3998+ case SDL_SCANCODE_F6:
3999 if (get_display_flag(dfDebug)) {
4000 GameChatMenu::create_script_console(
4001 this, m_debugconsole, *DebugConsole::get_chat_provider());
4002
4003=== modified file 'src/wui/interactive_base.h'
4004--- src/wui/interactive_base.h 2014-09-20 09:37:47 +0000
4005+++ src/wui/interactive_base.h 2014-11-02 20:06:40 +0000
4006@@ -22,7 +22,7 @@
4007
4008 #include <memory>
4009
4010-#include <SDL_keysym.h>
4011+#include <SDL_keycode.h>
4012
4013 #include "logic/editor_game_base.h"
4014 #include "logic/map.h"
4015@@ -135,7 +135,7 @@
4016 void minimap_warp(int32_t x, int32_t y);
4017
4018 void draw_overlay(RenderTarget &) override;
4019- bool handle_key(bool down, SDL_keysym) override;
4020+ bool handle_key(bool down, SDL_Keysym) override;
4021
4022 void unset_sel_picture();
4023 void set_sel_picture(const char * const);
4024
4025=== modified file 'src/wui/interactive_player.cc'
4026--- src/wui/interactive_player.cc 2014-10-27 08:06:06 +0000
4027+++ src/wui/interactive_player.cc 2014-11-02 20:06:40 +0000
4028@@ -365,7 +365,7 @@
4029 * \li Pause: pauses the game
4030 * \li Return: write chat message
4031 */
4032-bool InteractivePlayer::handle_key(bool const down, SDL_keysym const code)
4033+bool InteractivePlayer::handle_key(bool const down, SDL_Keysym const code)
4034 {
4035 if (down) {
4036 switch (code.sym) {
4037@@ -405,7 +405,7 @@
4038 g_gr->toggle_fullscreen();
4039 return true;
4040
4041- case SDLK_KP7:
4042+ case SDL_SCANCODE_KP_7:
4043 if (code.mod & KMOD_NUM)
4044 break;
4045 /* no break */
4046@@ -413,7 +413,7 @@
4047 move_view_to(game().map().get_starting_pos(m_player_number));
4048 return true;
4049
4050- case SDLK_KP_ENTER:
4051+ case SDL_SCANCODE_KP_ENTER:
4052 case SDLK_RETURN:
4053 if (!m_chatProvider | !m_chatenabled || !is_multiplayer())
4054 break;
4055
4056=== modified file 'src/wui/interactive_player.h'
4057--- src/wui/interactive_player.h 2014-09-10 14:48:40 +0000
4058+++ src/wui/interactive_player.h 2014-11-02 20:06:40 +0000
4059@@ -61,7 +61,7 @@
4060
4061 void node_action() override;
4062
4063- bool handle_key(bool down, SDL_keysym) override;
4064+ bool handle_key(bool down, SDL_Keysym) override;
4065
4066 Widelands::Player & player() const {
4067 return game().player(m_player_number);
4068
4069=== modified file 'src/wui/interactive_spectator.cc'
4070--- src/wui/interactive_spectator.cc 2014-09-10 16:57:31 +0000
4071+++ src/wui/interactive_spectator.cc 2014-11-02 20:06:40 +0000
4072@@ -243,7 +243,7 @@
4073 /**
4074 * Global in-game keypresses:
4075 */
4076-bool InteractiveSpectator::handle_key(bool const down, SDL_keysym const code)
4077+bool InteractiveSpectator::handle_key(bool const down, SDL_Keysym const code)
4078 {
4079 if (down)
4080 switch (code.sym) {
4081@@ -268,7 +268,7 @@
4082 return true;
4083
4084 case SDLK_RETURN:
4085- case SDLK_KP_ENTER:
4086+ case SDL_SCANCODE_KP_ENTER:
4087 if (!m_chatProvider | !m_chatenabled)
4088 break;
4089
4090
4091=== modified file 'src/wui/interactive_spectator.h'
4092--- src/wui/interactive_spectator.h 2014-09-10 16:57:31 +0000
4093+++ src/wui/interactive_spectator.h 2014-11-02 20:06:40 +0000
4094@@ -44,7 +44,7 @@
4095
4096 Widelands::Player * get_player() const override;
4097
4098- bool handle_key(bool down, SDL_keysym) override;
4099+ bool handle_key(bool down, SDL_Keysym) override;
4100
4101 private:
4102 void toggle_chat();
4103
4104=== modified file 'src/wui/mapview.cc'
4105--- src/wui/mapview.cc 2014-09-27 18:53:55 +0000
4106+++ src/wui/mapview.cc 2014-11-02 20:06:40 +0000
4107@@ -192,7 +192,7 @@
4108 if (!intbase().get_sel_freeze())
4109 track_sel(Point(x, y));
4110
4111- g_gr->update_fullscreen();
4112+ g_gr->update();
4113 return true;
4114 }
4115
4116
4117=== modified file 'src/wui/quicknavigation.cc'
4118--- src/wui/quicknavigation.cc 2014-09-10 08:55:04 +0000
4119+++ src/wui/quicknavigation.cc 2014-11-02 20:06:40 +0000
4120@@ -86,7 +86,7 @@
4121 m_havefirst = true;
4122 }
4123
4124-bool QuickNavigation::handle_key(bool down, SDL_keysym key)
4125+bool QuickNavigation::handle_key(bool down, SDL_Keysym key)
4126 {
4127 if (!m_havefirst)
4128 return false;
4129@@ -98,8 +98,8 @@
4130 assert(which < 10);
4131
4132 bool ctrl =
4133- WLApplication::get()->get_key_state(SDLK_LCTRL) ||
4134- WLApplication::get()->get_key_state(SDLK_RCTRL);
4135+ WLApplication::get()->get_key_state(SDL_SCANCODE_LCTRL) ||
4136+ WLApplication::get()->get_key_state(SDL_SCANCODE_RCTRL);
4137 if (ctrl) {
4138 m_landmarks[which].point = m_current;
4139 m_landmarks[which].set = true;
4140
4141=== modified file 'src/wui/quicknavigation.h'
4142--- src/wui/quicknavigation.h 2014-09-14 11:31:58 +0000
4143+++ src/wui/quicknavigation.h 2014-11-02 20:06:40 +0000
4144@@ -47,7 +47,7 @@
4145
4146 void view_changed(Point point, bool jump);
4147
4148- bool handle_key(bool down, SDL_keysym key);
4149+ bool handle_key(bool down, SDL_Keysym key);
4150
4151 private:
4152 void setview(Point where);
4153
4154=== modified file 'src/wui/shipwindow.cc'
4155--- src/wui/shipwindow.cc 2014-09-10 13:03:40 +0000
4156+++ src/wui/shipwindow.cc 2014-11-02 20:06:40 +0000
4157@@ -291,7 +291,7 @@
4158 /// Sink the ship if confirmed
4159 void ShipWindow::act_sink()
4160 {
4161- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
4162+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
4163 m_igbase.game().send_player_sink_ship(m_ship);
4164 }
4165 else {
4166@@ -302,7 +302,7 @@
4167 /// Cancel expedition if confirmed
4168 void ShipWindow::act_cancel_expedition()
4169 {
4170- if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
4171+ if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
4172 m_igbase.game().send_player_cancel_expedition_ship(m_ship);
4173 }
4174 else {
4175
4176=== modified file 'utils/macos/build_app.sh'
4177--- utils/macos/build_app.sh 2014-10-16 04:54:10 +0000
4178+++ utils/macos/build_app.sh 2014-11-02 20:06:40 +0000
4179@@ -1,6 +1,6 @@
4180 #!/bin/bash
4181
4182-set -e
4183+set -e
4184
4185 if [ "$#" == "0" ]; then
4186 echo "Usage: $0 <bzr_repo_directory>"
4187@@ -35,7 +35,7 @@
4188 cp $SOURCE_DIR/COPYING $DESTINATION/COPYING.txt
4189
4190 echo "Creating DMG ..."
4191- hdiutil create -fs HFS+ -volname "Widelands $WLVERSION" -srcfolder "$DESTINATION" "$UP/widelands_64bit_$WLVERSION.dmg"
4192+ hdiutil create -fs HFS+ -volname "Widelands $WLVERSION" -srcfolder "$DESTINATION" "$UP/widelands_64bit_$WLVERSION.dmg"
4193 }
4194
4195 function MakeAppPackage {
4196@@ -88,8 +88,8 @@
4197 cp -a src/widelands $DESTINATION/Widelands.app/Contents/MacOS/
4198
4199 echo "Stripping binary ..."
4200- strip -u -r $DESTINATION/Widelands.app/Contents/MacOS/widelands
4201-
4202+ strip -u -r $DESTINATION/Widelands.app/Contents/MacOS/widelands
4203+
4204 echo "Copying dynamic libraries ..."
4205 dylibbundler -od -b -x $DESTINATION/Widelands.app/Contents/MacOS/widelands -d $DESTINATION/Widelands.app/Contents/libs
4206 }
4207@@ -106,26 +106,26 @@
4208 -DWL_PATHS_ARE_ABSOLUTE:STRING="false" \
4209 -DCMAKE_PREFIX_PATH:PATH="/usr/local" \
4210 \
4211- -DSDL_LIBRARY:STRING="-L/usr/local/lib /usr/local/lib/libSDLmain.a /usr/local/lib/libSDL.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit" \
4212- -DSDL_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4213+ -DSDL2_LIBRARY:STRING="-L/usr/local/lib /usr/local/lib/libSDL2main.a /usr/local/lib/libSDL2.a -Wl,-framework,OpenGL -Wl,-framework,Cocoa -Wl,-framework,ApplicationServices -Wl,-framework,Carbon -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,IOKit" \
4214+ -DSDL2_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4215 \
4216- -DSDLIMAGE_LIBRARY:STRING="-Wl,/usr/local/lib/libSDL_image.a -Wl,/usr/local/lib/libjpeg.a" \
4217- -DSDLIMAGE_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4218+ -DSDL2IMAGE_LIBRARY:STRING="-Wl,/usr/local/lib/libSDL2_image.a -Wl,/usr/local/lib/libjpeg.a" \
4219+ -DSDL2IMAGE_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4220 \
4221 -DPNG_LIBRARY:FILEPATH="/usr/local/opt/libpng/lib/libpng.a" \
4222 -DPNG_INCLUDE_DIR:PATH="/usr/local/opt/libpng/include" \
4223 \
4224- -DSDLTTF_LIBRARY:STRING="-Wl,/usr/local/opt/freetype/lib/libfreetype.a -Wl,/usr/local/lib/libbz2.a -Wl,/usr/local/lib/libSDL_ttf.a" \
4225- -DSDLTTF_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4226- \
4227- -DSDLGFX_LIBRARY:FILEPATH="/usr/local/lib/libSDL_gfx.a" \
4228- -DSDLGFX_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4229- \
4230- -DSDLMIXER_LIBRARY:STRING="-Wl,/usr/local/lib/libvorbisfile.a -Wl,/usr/local/lib/libogg.a -Wl,/usr/local/lib/libvorbis.a -Wl,/usr/local/lib/libSDL_mixer.a" \
4231- -DSDLMIXER_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4232- \
4233- -DSDLNET_LIBRARY:FILEPATH="/usr/local/lib/libSDL_net.a" \
4234- -DSDLNET_INCLUDE_DIR:PATH="/usr/local/include/SDL" \
4235+ -DSDL2TTF_LIBRARY:STRING="-Wl,/usr/local/opt/freetype/lib/libfreetype.a -Wl,/usr/local/lib/libbz2.a -Wl,/usr/local/lib/libSDL2_ttf.a" \
4236+ -DSDL2TTF_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4237+ \
4238+ -DSDL2GFX_LIBRARY:FILEPATH="/usr/local/lib/libSDL2_gfx.a" \
4239+ -DSDL2GFX_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4240+ \
4241+ -DSDL2MIXER_LIBRARY:STRING="-Wl,/usr/local/lib/libvorbisfile.a -Wl,/usr/local/lib/libogg.a -Wl,/usr/local/lib/libvorbis.a -Wl,/usr/local/lib/libSDL2_mixer.a" \
4242+ -DSDL2MIXER_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4243+ \
4244+ -DSDL2NET_LIBRARY:FILEPATH="/usr/local/lib/libSDL2_net.a" \
4245+ -DSDL2NET_INCLUDE_DIR:PATH="/usr/local/include/SDL2" \
4246 \
4247 -DINTL_LIBRARY:STRING="-Wl,/usr/local/opt/libiconv/lib/libiconv.a -Wl,/usr/local/opt/gettext/lib/libintl.a" \
4248 -DINTL_INCLUDE_DIR:PATH="/usr/local/opt/gettext/include" \

Subscribers

People subscribed via source and target branches

to status/vote changes: