* Removed display::screen_area(), display::w(), and display::h().
* Moved the global screen_area() function into the CVideo class.
* Renamed CVideo::getx() and gety() to get_width() and get_height()
* Made those two functions return the result of screen_area() instead of the other way around.
* Added preliminary support for high-DPI rendering to screen_area()
Note on the last point: When I fixed bug #1772 (aa8f6c7e7 right now but will probably change with rebasing)
I noted that SDL_GetWindowSize and SDL_GetRendererOutputSize returned the same results for me (even with
Window's automatic scaling for non-high-DPI-enabled apps disabled) but that the SDL documentation stated the
former returned screen coordinates and the latter pixels. In that same commit I changed the dimension functions
to use SDL_GetWindowSize. I've now reversed that decision and gone back to using SDL_GetRendererOutputSize so
I can guarantee output in pixels. If use_pixels is false, the code will return coordinates in 96 DPI, so I need
to have pixel measurements for the calculations.
Again, though, I do not know if SDL_GetWindowSize returns a different value that pixel size (which it's said
to do) on macOS or iOS. I'll need to do some testing. It's possible on those platforms I won't need the 96 DPI
measurements, but it's also possible it will be needed on on platforms, since all of our code relies on pixel
measurements.
This involves splitting standard colors out of font/constants.cpp.
Serialization/string_utils.cpp, that is part of wesnothlib
(compiled into both client and server) uses ellipsis and Unicode minus sign
from font constants, which means that font/constants.cpp must be part of
wesnothlib as well. However, one of standard colors is evaluated by calling
inverse(const SDL_Color&) declared in sdl/utils.hpp. Sdl/utils.cpp has way
too many dependencies to live in wesnothlib.
Hence, standard colors are now in a file of their own:
font/standard_colors.cpp. That file is part of wesnoth (not wesnothlib) and
only available for the client.
Commands run:
find . -type f -name "*.hpp" | xargs coan source --replace --no-transients -U"SDL_GPU"
find . -type f -name "*.cpp" | xargs coan source --replace --no-transients -U"SDL_GPU"
This was followed by grepping and a bit of manual editing to remove
defunct TODO items and the empty sdl/gpu.hpp file.
Since GUI1 widgets seem to rely on the given font size values in font.hpp
for their dimensions, those are unchanged. ThemeWML-provided sizes were adjusted,
and larger sizes assigned to elements that were too small with the new font.
Theme element rects were also adjusted as necessary.
This makes the map-editor aware of the draw-layering. Since it's a
subclass of the display-class, but relies on the buttons being
re-created in the superclass I've moved that code into the subclass
instead. This way there won't be any infinite loops with a full redraw
triggering another full redraw.
I have also introduced a small workaround in the GUI1 button widget,
where it would sometimes add the postfix to overlay image names that
already contained the postfix. If the image name ends in the postfix,
the postfix is removed from the name before re-added. This ensures
that the files are successfully found.
This adds the necessary bells and whistles to resize the GUI1 buttons
used in the main game display. It is rather painful as it involves
re-setting most of the attributes that affect the size.
These changes also adds two new draw-methods to the display class and
gets rid of the default parameters. This is to avoid warnings from
clang since the draw() method comes from a superclass to display now.
The GUI1 button's set_image has been updated to treat the image path
in the same way as it is treated in the constructor. This should not
be a problem since the method is not called from anywhere but the
display class, and that call is added in this commit.
This adds dynamic layout functionality, which is invoked on a full
redraw and upon element creation. It also makes sure that there's no
attempt to do a surface restore on negative widhts or heights as
introduced support for in SDL2. Finally, there's a workaround for text
being clipped by 1-2 pixels in GUI1 buttons.
This fixes bugs #24211, #24214, #24213, #24209, #19666, #23534.
The GUI1 components have been made window event aware and will redraw
themselves after a window event.
This partially reverts an earlier commit
28fe7e44
instead of changing the exception type to game::game_error,
(which I assume is meant for in-game errors?), we go back to
game::error which is now handled properly in playcampaign.cpp
and game_launcher.cpp
Tested that this does not reintroduce bug 22611.
This is a chearry pick by me (gfgtdf) of 66176b1738. It differes a lot from the original becasue since there were so much merging conflics i decided to do it mostly from scratch.
Conflicts:
src/addon/manager.cpp
src/addon/manager_ui.cpp
src/campaign_server/campaign_server.cpp
src/config_cache.cpp
src/create_engine.cpp
src/editor/map/context_manager.cpp
src/editor/map/map_context.cpp
src/font.cpp
src/game_config_manager.cpp
src/gamestatus.cpp
src/gui/dialogs/editor/custom_tod.cpp
src/gui/dialogs/lobby/lobby_data.cpp
src/gui/dialogs/mp_create_game.cpp
src/gui/widgets/settings.cpp
src/hotkeys.cpp
src/image.cpp
src/multiplayer_lobby.cpp
src/network.cpp
src/playcampaign.cpp
src/preferences.cpp
src/savegame.cpp
src/serialization/preprocessor.cpp
src/tests/main.cpp
src/wesnoth.cpp
src/widgets/button.cpp
If the main button image could not be loaded, the previous code
would throw an exception of an obscure type "error". It appears that
this was not caught anywhere except the main function in wesnoth.cpp
and so the program would close immediately.
I first tried to go into the gui initialization and construct
buttons in try catch blocks, skipping ones that have problems, but
rather than being able to proceed, this just causes a segfault
because other parts of the code assume that all buttons have been
constructed successfully. This means that not finding the image is
necessarily a fatal error.
My fix for the problem is, instead of throwing error, we throw the
more standard "game::game_error". The new behavior is, if you try
to load a theme with nonexistant images, then a black screen will
appear with a dialog
"error initializing button images! filename: buttons/dontexist.png"
The game then returns to the title screen.
Conflicts:
src/widgets/button.cpp
(just the #include reorder)
This is the result of running this command in directory src/
find . -type f -exec sed -i 's/\(ERR.*\)\\n\"\;/\1\" << std::endl\;/g' '{}' \;
and carefully inspecting the results.