Commit graph

592 commits

Author SHA1 Message Date
Martin Hrubý
50301f84e3 Fix building with Xcode 10 (#3460)
Resolves #3458.
2018-08-16 15:06:00 +03:00
Martin Hrubý (hrubymar10)
bc4d22dc72 Migrate links to https if available - Fwd c18537edc0 2018-07-16 19:07:08 +11:00
Charles Dang
40d9b9953b Cleaned up some unused stuff from the display class
Namely complete_redraw_event(), recalculate_minimap(), and redraw_minimap(). I had
been keeping the last around for reference (see f5ec886cb5) but I
figure it's not really worth it since this isn't the drawing method we'll want to
be using in the end anyway.
2018-05-28 15:14:39 +11:00
Charles Dang
0dc5656c32 Convert C-style casts to static_cast 2018-05-13 22:36:50 +11:00
Charles Dang
69d7413a75 Display: some code cleanup
* Consolidate reinit_flags_for_side and init_flags_for_side_internal
* Made use of the team/map/unit getters.
2018-04-29 12:56:13 +11:00
Charles Dang
4818312150 Display: renamed get_disp_context to current_display_context
This is to avoid confusion with filter_context::get_disp_context. display used to
inherit from filter_context, but that was refactored out a while back. I left
get_disp_context since it was used and useful, but I realize now it causes more
confusion than not.

Also converted help::load_terrain_types_data to use get_map() directly since I
noticed it.

And changed a stray use of `thedisp` to `disp` in unit_drawer. Doesn't do anything
but it was bugging me.
2018-04-20 17:00:40 +11:00
Charles Dang
e583c470be Display: cleaned up overlay map getter interface
Instead of a pointer to a member of a derived class, used a virtual function implemented
in both derived classes (game_display and editor_display) that return an reference to the
appropriate object.

Also removed the overlay.hpp include from display.hpp. We can forward-declare the overlay
struct.
2018-04-20 10:48:39 +11:00
Charles Dang
f5ec886cb5 Display: removed minimap drawing code
I kept some helper code (mainly the redraw_minimap function so I know where it needs
to be called) around for references.
2018-04-06 15:52:21 +11:00
Charles Dang
b8d051cb72 Moved game version stuff from game_config.hpp to version.hpp
They're still in the game_config namespace but are now in a more logical header.

game_config::version has been replaced with wesnoth_version.str(), save for one case
where it was replaced with wesnoth_version directly (it was a comparison against another
version_info object; no need to compare against a string...).

Also cleaned up a bunch of game_config.hpp includes.
2018-04-04 22:08:18 +11:00
Charles Dang
34797ed1a2 Removed or commented out (for reference) all uses of the GUI1 button widget
And removed said widget.
2018-03-26 13:13:17 +11:00
Charles Dang
49d36e6eb4 Display: always draw the map in the full window
This is a temporary measure that removes reliance on the theme map rect.
I need to ponder the best design to handle displaying the full map.
2018-03-24 14:36:40 +11:00
Charles Dang
5ece7ac5b7 Split the rect_of_hexes struct into its own file
And cleaned up it a bit. Made use of std::array and gave it a default ctor using
the values from display::hexes_under_rect.
2018-03-24 13:22:54 +11:00
Charles Dang
b6c4f0f6ae Display: removed redraw observer interface
This won't be needed once we get everything sorted out and refactored.
2018-03-23 12:23:58 +11:00
Charles Dang
4ea25d5df5 Display: removed more theme handling stuff 2018-03-22 14:46:34 +11:00
Charles Dang
37dee4b1ff Display: removed all code related to report drawing
Report drawing was handled in draw_sidebar, so that function was also removed. The display
class won't be handling sidebar drawing anymore anyway.

Also removed display::invalidate_game_status and game_display::invalidate_unit which were
both used to set a flag dealing with report drawing.

This should finally get the display class close to map drawing only.
2018-03-22 04:20:38 +11:00
Charles Dang
5145b009a5 Display: removed code to draw theme panels/labels
Again, going to be handled by a GUI2 dialog.
2018-03-21 14:38:51 +11:00
Charles Dang
72c451d2ae Display: restored background drawing
I think we indeed want this to be handled here, since it's the gamemap background,
not the UI's background. Made it a class member.
2018-03-21 14:15:52 +11:00
Charles Dang
e1e7f65ec1 Display: removed interface that set up theme buttons
Unused now, since we're moving to GUI2 for the ingame UI. The functions to get buttons
are left, but they always return nullptr.
2018-03-21 14:15:50 +11:00
Charles Dang
3254bb2c7d Moved UI object from display to play_controller
Design change from 075a9bac34.

After discussion with @celticminstrel, we decided it better for the controller to
own the UI object as well as the display object, instead of the display owning the UI.

I've added a pure virtual function declaration to controller_base to ensure all controllers
implement this.
2018-03-21 13:13:54 +11:00
Charles Dang
fef1310890 Attempt to fix build 2018-03-21 08:26:32 +11:00
Charles Dang
239fde451a Removed the old surface drawing queue implementation, except for the layer enum
Kept that since it's still used in some places and is good for reference.
Also removed display::get_screen_surface which was used in said impl.
2018-03-20 22:07:34 +11:00
Charles Dang
504d4d2ff4 Display: removed now-unused map_screenshot_surface_
Unused as of 3a768cbdbe. It was needed for get_screen_surface(), which is used in
drawing_queue, but that's going to be removed soon.
2018-03-20 10:29:42 +11:00
Charles Dang
075a9bac34 Get the GUI2 in-game UI at least appearing
I decided to go with a modular approach, where both in-game and editor UI dialogs inherit
from a single base class, a pointer of which is owned by the display class. That can be
used for common functionality that needs be shared by all in-game dialogs.

Right now the new UI is just static. It works with most stuff, but not key presses. Working
on that...
2018-03-20 04:47:42 +11:00
Charles Dang
b2d3da4a1e Removed non-functional video2::draw_layering class
Will possibly re-implement this in a different way.
2018-03-20 04:47:40 +11:00
Charles Dang
ace03abef5 Display: removed unused redraw_everything function 2018-03-19 17:00:15 +11:00
Charles Dang
9063736fd4 Display: removed drawing_queue_ member
This was the core of the surface-based drawing engine. Unused now. The drawing_queue_add()
calls throughout the code have been left, but commented out, for reference while reimplementing
things. The actual drawing_queue code has been left to, since its layers are referenced in
places. Need to remove them.
2018-03-19 16:59:44 +11:00
Charles Dang
fc2a58f693 Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/
2018-03-19 11:56:04 +11:00
Gregory A Lundberg
f97a617a26
Fix doccomments. 2018-03-18 13:18:12 -05:00
Gregory A Lundberg
5b371161a7
Add missing override specifier. 2018-03-18 12:07:47 -05:00
Charles Dang
90b2a51c46 display general compilation fixes 2018-03-19 01:31:34 +11:00
Charles Dang
2ba020a746 Display: avoid temp vectors when rendering partial fog/shround images on hex 2018-03-19 01:30:31 +11:00
Charles Dang
eeece5e3c7 Display: exit render_scaled_to_zoom early if passed texture is null 2018-03-19 01:30:30 +11:00
Charles Dang
8eba15bffc 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.
2018-03-19 01:29:41 +11:00
Charles Dang
3376ef04e3 Another large batch of progress, primarily in game_display
This is primarily focused on getting various areas of the game display drawing, such as footstep images
and the terrain defense indicators.

To facilitate the last, I've refactored draw_text_in_hex to utilize floating labels instead of drawing
to hex directly with surfaces. This probably isn't the most optimal solution, since labels are continuously
created and destroyed, but since their text is usually short and cached in the rendered text cache it
does for now.

Also includes some cleanup of deprecated functions in display, and slight reordering of drawing order of
certain elements.
2018-03-19 01:29:34 +11:00
Charles Dang
f8e71f4d9a Display: avoid unnecessarily (potentially) creating millions of temp vectors
I've moved the terrain hex drawing code directly into draw_visible_hexes instead of relying on get_terrain_images
to return a vector of all the necessary images for each visible hex and then drawing them. Instead, we now draw
each hex's images immediately without any intermediary container.

With the old method, after about 10 to 15 seconds of drawing we had already allocated (and destroyed) almost 180,000
temporary vectors (a new one was created for each hex, twice per draw cycle). It's obvious how quickly that would add
up over a normal play session, and though in this case the performance hit for creating each vector was probably tiny,
creating them likely would have added up.
2018-03-19 01:29:30 +11:00
Charles Dang
78bcd85d9f Display: cleaned up a bunch of now-unused/unnecessary members and functions 2018-03-19 01:26:14 +11:00
Charles Dang
cdb43343b4 Marked sdl_handler::draw overrides as final 2018-03-19 01:26:12 +11:00
Charles Dang
dadb31aadf Display: header formatting and doc updates
Appropriate functions were also marked deprecated.
2018-03-19 01:26:11 +11:00
Charles Dang
345fa27565 Display: work on refactoring the main drawing system
Previously, every visible hex was iterated over and every element in that hex draw. This was inefficient
for two reasons: First, it meant the performance footprint for many operations like unit drawing was O(n²),
since the list of elements had to be checked for every single hex. Second, it meant the renderer had to
switch active textures many more times than necessary.

My new system involved drawing every element of a specific type at once - ie, all background terrains at
once, all units, all items, etc. This reduces lookup time from O(n²) to O(n) and results in a noticeable
performance increase. It also reduces the number of times the renderer needs to switch active textures,
since bulk draws such as the map grid overlay are now done all at once while that specific texture is
active.

There are still some layering issues and missing elements that need to be sorted, especially in game_display.
2018-03-19 01:26:07 +11:00
Charles Dang
a86ac0675f Display: removed old drawing code and external draw calls 2018-03-19 01:23:09 +11:00
Charles Dang
c5be598cd0 Display: removed all the invalidated locations code
This removes all the code related to invalidating locations, any functions used to set, modify, or propagate
location invalidation, and several functions that no longer serve any purpose anymore since their only purpose
was to handle invalidated locations.
2018-03-19 01:23:06 +11:00
Charles Dang
d23d1ea338 Renamed drawing_buffer to drawing_queue
Also renamed drawing_queue::drawing_layer to just 'layer'.
2018-03-19 01:22:28 +11:00
Charles Dang
643ebe221f Got a bunch more components drawing
Reachmaps, attack indicators, shroud/fog (incomplete).
2018-03-19 01:21:04 +11:00
Charles Dang
42894f6ac3 Another huge chunk of progress 2018-03-19 01:17:05 +11:00
Charles Dang
d2087a14c4 Initial refactor for main-screen accelerated rendering 2018-03-19 01:16:01 +11:00
Charles Dang
8dc661db40 Decoupled drawing buffer code from display class 2018-03-19 01:14:02 +11:00
Jyrki Vesterinen
267510ea07 Show screenshot window before saving the screenshot
In particular, this allows the player to choose the filename before saving,
including the extension. If support for target format is present, Wesnoth
honors the extension and saves the screenshot in that format.

I also changed the default screenshot format back to PNG due to quality
issues JPEG has with pixel art. See discussion in pull request #2655.

This commit doesn't introduce any string changes. I used existing strings
for everything (sometimes having to take them from another textdomain).
2018-03-16 23:45:36 +02:00
Charles Dang
4ba33d464e Cleaned up text rendering-related includes 2018-03-11 21:46:21 +11:00
Charles Dang
e270a7c665 Formatting cleanup: > > to '>>`
Allowed since C++11. Might as well use it everywhere.
2018-02-21 12:11:21 +11:00
Charles Dang
1855266104 Fixed standing animation toggle not taking immediate effect (fixes #1653) 2018-02-14 10:46:51 +11:00