Commit graph

95 commits

Author SHA1 Message Date
Martin Hrubý (hrubymar10)
bc4d22dc72 Migrate links to https if available - Fwd c18537edc0 2018-07-16 19:07:08 +11:00
Charles Dang
2ec5c6ee5c Cleaned up more unnecessary includes 2018-04-21 23:19:55 +11:00
Charles Dang
f25a404f37 Refactored floating_label implementation
* Store label as a texture instead of creating a texture from a surface every draw cycle
* Restored expired label removal and alpha fadeout (was accidentally removed earlier in my refactoring)
* Use alpha field of bg_color member for background color
* Draw tooltip backgrounds procedurally instead of with surfaces and part of the label texture itself.
  See included comment for small caveat.
2018-03-19 01:22:21 +11:00
Charles Dang
f5effa03f3 Tooltips: increased bg opacity to match GUI2 ones
Makes it easier to read the text too.
2018-03-18 17:01:25 +11:00
Charles Dang
4ba33d464e Cleaned up text rendering-related includes 2018-03-11 21:46:21 +11:00
Charles Dang
16ce2af32e Made display class no longer inherit from filter_context
The only function that display meaningfully implemented was get_disp_context. It did implement
get_tod_man, but only meaningfully in its two derived classes (it returned the result of
resources::tod_manager in display). Additionally, the long-ass comment in the header stated the
display class should *not* inherit from filter_context. Do note that get_disp_context was retained
as a display member function.

Upon further investigation, I found that there were only two places where the display class was
passed to unit_filter. All others passed resources::filter_con. The editor_display class was also
assigned to resources::filter_con in editor::context_manager. So, I removed the second filter_context
argument from unit_filter and initialized it from resources::filter_con in all cases.

unit_filter only used the filter_context to get its display_context and the unit_map within anyway.
When using display::get_disp_context in-game, that would return a game_board object. Using
resources::filter_con in the same context would return the game_state object that owned the
aforementioned game_board, and calling get_disp_context on that game_state would return the board
as well. So we end up in the same place.

To be complete, I also made editor::context_manager inherit from filter_context. It makes much more
sense, since it can nicely implement 2/4 of the fc functions. It also ensures resources::filter_con
is valid in the editor, in case it's needed. I'm not 100% sure it is, but since it was assigned
before (to editor_display), it's very likely.

Another side effect of the above is that get_tod_man is now implemented in a more apropos class
in the editor. Essentially, editor_display (where it was implemented before by reaching into the
context_manager) holds an editor_controller which holds a context_manager (where it's now implemented).
It wasn't even really needed in editor_display and was only called once.

Similarly, get_tod_man has been removed from game_display. Again, it was only present to "properly"
implement the function in display, which only existed because display inherited from filter_context.
And get_tod_man wasn't even needed in display, game_display, or editor_display (save for the one
aforementioned call)!!! AND in game_display, it simply dereferenced a pointer to the *actual* ToD
manager in the game_state class, WHICH IN AND OF ITSELF INHERITS FROM FILTER_CONTEXT!!!

I have removed the tod_manager pointer in game_display and replaced its use with resources::tod_manager,
which in the context of the game (where game_display) would be use, point to the same thing the class
pointer did. I suppose I could have left it, since I'm trying to remove/improve the use of the
resources pointers, but I felt it better to decouple the two classes (game_display and game_state)
slightly, especially since its main purpose for existing (overriding display::get_tod_man) no longer
exists.

Finally, some of the instances where a unit_filter object is created had to be changed to use brace
initialization or else the build failed. @celticminstrel tells me this might be because of some "most
vexing parse" issue.

Some formatting and virtual/override specifiers were also applied/added.

*huffs*
2018-01-29 15:54:01 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
29ff4bd644 Removed CVideo argument from help functions
Just used the singleton in the main show_help function.
2017-12-05 10:50:11 +11:00
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
9dd497db4a Cleaned up the mess of CVideo references passed around the game initialization process
Essentially, we had CVideo arguments being passed down this chain:
- game_launcher
- free-standing MP initialization functions
- campaign_controller
- playsingle_controller/playmp_controller
- play_controller
- game_display
- display

And likewise down through
- game_launcher
- editor_controller
- editor_display
- display

With only a minimal number of actual calls along the way. :| There were maybe... two remaining?

This removes the CVideo arguments and class members from both chains (except of course, game_launcher.
That's where the "real" CVideo object lives).

The display class now initializes its CVideo reference from the singleton, which is also used in the
very few other places it's needed. I also replaced a check for a null video ptr in show_tooltip()
with a faked() check (see src/tooltips.cpp). That seems to make more sense, since CVideo is never
null now.
2017-11-21 02:30:19 +11:00
Charles Dang
61992429d0 Avoid copy initialization of colors when possible 2017-04-15 21:10:42 +11:00
Charles Dang
0c3260dc05 Finished deploying std::map::emplace (cont. e1a579da51)
Apparently, the last time I did this I only grepped for `insert(std::pair` not `insert(std::make_pair`. Oversight, much?
2017-04-12 07:51:42 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
60fc61a9a0 Cleaned up a few SDL includes 2017-03-14 10:56:35 +11:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +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
Charles Dang
30c1a852d3 Attempt to fix compilation 2016-10-16 22:52:54 +11:00
Celtic Minstrel
db5cf990de Fix use of constexpr 2016-10-16 01:45:05 -04:00
Chris Beck
f82f996347 move font constants to their own compilation unit
avoids including SDL_TTF unnecessarily
2016-10-15 12:38:52 -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
Charles Dang
ea0a9ff43b Bumped size of GUI1 tooltip text
Was left too small after enabling Lato in GUI1 (52cba5fc63)
2016-05-18 10:57:42 +11:00
Celtic Minstrel
ca382018b7 BOOST_FOREACH -> range for 2016-04-02 09:38:29 -04: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
37d9b102b7 Include SDL files as system headers
This excludes inclusions in SDL_GPU files.
2016-03-20 15:07:16 +11:00
gfgtdf
a953848dda remove display dependency from show_help()
help_button still needs a display& for regierting it in the hotkey code.
2016-01-12 23:17:56 +01: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
Ignacio R. Morelle
aecdbab096 Pass object by reference
Found by cppcheck.
2015-07-06 23:42:13 -03:00
Chris Beck
ea212b5bc2 move class floating_label from font.cpp to its own file
floating_label is essentially a primitive GUI1 widget, consisting
just of a text label and non-interacting. It's also used for the
map labels displayed in-game iiuc.
2015-03-07 21:22:03 -05:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Fabian Müller
7525c2ed4c Allow removing labels by handle. 2014-12-13 07:31:46 +01:00
Fabian Müller
8e118e4a40 Add support for setting the drawing content of tooltips. 2014-12-13 01:07:38 +01:00
Chris Beck
a02235a567 move the help browser files into their own folder
This is the start of a refactor to make all the help code more
easy to follow.
2014-11-11 01:24:44 -05:00
Chris Beck
06b05067b5 finish fix up in aabdd2969a 2014-06-19 14:01:02 -04:00
Chris Beck
78b538bc1f fixup includes, remove include SDL.h from src/events.hpp 2014-06-19 11:11:05 -04:00
Chris Beck
0ce40e751c catch exceptions thrown in tooltips manager dtor 2014-06-07 23:41:26 -04:00
Boldizsár Lipka
ac96a2b91b Move some functions to sdl/rect. 2014-06-03 10:30:12 +02:00
Ignacio R. Morelle
a4f47a63c7 New Year copyright update 2014-01-01 02:08:52 -03:00
mattsc
4bfd2240e2 Tooltips: ensure that 'use_markup' is always passed by add_tooltip()
Not all parts of add_tooltip() did so previously, resulting in pango
markup of tooltips not always working.  For example, in some cases it
only worked for tooltips on the first mouse-over, but not on subsequent
ones.  That is fixed now.
2013-11-18 18:03:01 -08:00
Eric S. Raymond
043c4f9fd3 Remove $Id$ cookies. 2013-03-26 21:41:37 -04:00
Mark de Wever
43b71f2ff0 New year copyright update. 2013-01-01 09:22:03 +00:00
Sergey Popov
6b6eafb213 Use BOOST_FOREACH directly instead of #define foreach BOOST_FOREACH
The define is extremely unreliable, will break compile with boost >=
1.50 and upstream can't fix issues with it, see
https://svn.boost.org/trac/boost/ticket/6131
2012-07-07 00:49:45 +00:00
Mark de Wever
49eb8c10b1 Ignore Pango markup in map descriptions.
Fixes bug #19210, patch provided by Shadow master.
2012-03-18 14:57:32 +00:00
Ignacio R. Morelle
6ca69b2df5 New year copyright update 2012-01-07 02:35:17 +00:00
Nils Kneuper
a9c341e278 "tiny gui support"-removal part 1:
removed all the if(n)defs from the sources (please review that I got
everything right!)

TODO: remove from build systems and data/
2011-02-12 16:20:24 +00:00
Mark de Wever
ecbabea838 New year copyright update. 2011-01-01 15:57:50 +00:00
Ignacio R. Morelle
d6a3de1938 Apply patch #2213 by stikonas, using file #11274 2010-11-21 01:56:29 +00:00
Guillaume Melquiond
eeb047de55 Fixed file headers so that they match the content of the COPYING file. 2010-09-01 21:12:38 +00:00
Ali El Gariani
992b6f0e3c Allow to associate a help page to each tooltip (open when clicking). 2010-06-04 18:59:18 +00:00