Commit graph

155 commits

Author SHA1 Message Date
Charles Dang
de1a9724eb Refactored handling of window/renderer size getters
* 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.
2017-12-05 10:50:10 +11:00
Charles Dang
8128093f61 Restrict 1000d9684 to overlays only
Allowing empty paths for buttons too breaks auto-assignment of non-specified button images in themes.
2017-05-05 14:19:44 +11:00
Charles Dang
1000d9684a GUI1: allow buttons to accept "" as a valid image path
This allows the editor to clear the palette group menu button overlay by passing "".
2017-05-02 17:15:29 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +11:00
Charles Dang
bf86912371 CVideo: removed update_rect functions
These have been functionally useless, since none of their code was ever executed. Since this hasn't caused
any problems this far, I'm removing them.
2016-12-07 00:41:11 +11:00
Charles Dang
4b3862493f Convert all usecases of SDL_Color to color_t 2016-11-30 17:59:30 +11:00
Jyrki Vesterinen
5e2af01fba Fix build
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.
2016-10-16 18:34:22 +03:00
Charles Dang
b6ea5106ca Moved marked-up_text.*pp to font/ 2016-10-16 22:54:07 +11:00
Chris Beck
1336306884 move font_options, text.?pp to font folder
also fix indentation in previous commit
2016-10-15 06:32:37 -04:00
Chris Beck
e3417bd954 split gui1 font interface into a font_config and sdl_ttf interface
move all of these into font folder
2016-10-15 05:52:23 -04:00
Andreas Löf
e497761d4e Remove SDL_GPU #idfefs and library
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.
2016-10-03 23:54:02 +13:00
Charles Dang
07e993ce3e Convert more cases of blit_surface to sdl_blit
Includes a change I forgot to include in 67348181f5
2016-09-25 15:50:42 +11:00
Charles Dang
52cba5fc63 Enabled Lato for GUI1 and adjusted assigned sizes accordingly
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.
2016-05-18 08:05:02 +11:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Charles Dang
5349552515 Add more comprehensive check for invalid button image loading (improves 0babe82b5b)
Also extends to button overlays
2016-02-29 11:24:44 +11:00
Andreas Löf
b576e1ae90 Ensure that the map-editor still works
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.
2016-02-25 22:10:59 +13:00
Andreas Löf
12d1fd006f Resize action buttons dynamically on the main display
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.
2016-02-24 20:45:50 +13:00
Andreas Löf
ac242376e9 Add a dynamic layout functionality to the game display
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.
2016-01-10 18:54:06 +13:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Andreas Löf
422ab07191 Add event handling to GUI and redraw on window events.
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.
2015-12-31 11:10:48 +13:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
7e5632d36c button ctor throws game::error when it can't find its image
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.
2014-11-04 15:53:24 -05:00
Chris Beck
abb3162fc2 fixup up gui1 button code interactions with filesystem
Image path modifiers should not be present when using the
filesystem::exists function. This fixes a bunch of error messages.
2014-10-24 13:47:05 -04:00
Alexander van Gessel (AI0867)
e5cb79b8e9 Move everything in src/filesystem.hpp into its own namespace
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
2014-10-13 18:31:18 +02:00
Chris Beck
28fe7e440c fixbug 22611: don't close the program if we can't find button image
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)
2014-09-13 12:18:58 -04:00
Boldizsár Lipka
2d822c25c1 Fix compilation. 2014-07-21 09:31:15 +02:00
Boldizsár Lipka
5fd034d3ef SDL_gpu support for GUI1 buttons. 2014-07-21 09:31:14 +02:00
Boldizsár Lipka
ac96a2b91b Move some functions to sdl/rect. 2014-06-03 10:30:12 +02:00
Chris Beck
3c9844889b Make sure all error logs flush with std::endl, so we get on travis.
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.
2014-05-20 15:37:52 -04:00
fendrin
dc9a2c89e4 Adds the option to use a suffix to the image paths.
Implemented for using image path functions.
A second change fixes size problems with image type buttons.
2014-03-15 14:37:16 +01:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
Charles Dang
06c757fc35 Corrected behavior of GUI1 button in regards to disabled states 2013-06-10 22:35:19 +11:00
Charles Dang
a801915784 Corrected default path for TURBO GUI1 button (lite -> menu_button_copper_H20) 2013-06-10 13:54:31 +11:00
Charles Dang
de3deab416 Fixed typo in a path 2013-06-09 01:11:50 +11:00
Charles Dang
7fe8cc5f84 Use grayscale IPF for disabled widget variations instead of specific images 2013-06-08 22:54:37 +11:00
Charles Dang
226578a31e Made default imagepath for GUI1 button non-copper 2013-06-04 20:45:56 +11:00
fendrin
5a5f3d7e94 Disable most of the palette buttons for the empty palette. 2013-05-17 12:17:36 +02:00
fendrin
1b375de815 Make use of the new button images (gui1). 2013-05-15 14:37:54 +02:00
fendrin
6fc50a6407 Fix missing icon overlays. 2013-05-12 22:00:33 +02:00
fendrin
74117329b8 Handle missing active overlay images properly. 2013-05-07 03:03:09 +02:00
fendrin
fd89e54dff Code clean up. 2013-05-06 20:51:57 +02:00
fendrin
782807c2f9 Made use of active overlay images. 2013-05-05 13:09:39 +02:00
fendrin
e49cc1f458 Default image for the turbo button type.
This fixes the widescreen theme.
2013-04-30 18:06:38 +02:00
fendrin
a1861e2aa3 Tooltip support in GUI1 widgets. 2013-04-29 16:33:50 +02:00
fendrin
63e4db2140 Support for changing the images during the runtime. 2013-04-13 19:42:22 +02:00
fendrin
3f8d6f5891 Enabled the use of the "disabled" image variants for gui1 buttons. 2013-04-05 22:21:58 +02:00
fendrin
26fb1edb6b Moved all editor specific buttons in their subfolder. Added
radiobuttons.
2013-04-02 01:00:11 +02:00
fendrin
51ab917bce Fix a bug with radio buttons not geting checked after out of area
movement.
2013-03-30 17:59:56 +01:00
fendrin
0921bd2378 Adjusted the radiobox behavior to the gtk+ one. 2013-03-30 16:37:04 +01:00