* Functions that return time values now return proper std::chrono::duration units (milliseconds,
seconds, etc.). This removes the need to do manual unit conversions.
* Simple time-to-execute logging was replaced with `utils::optimer`.
* Most uses of `SDL_GetTicks()` have been replaced with `std::chrono::steady_clock`.
* Uses of events::pump_info::ticks() have been replaced with direct calls to steady_clock::now().
This made the countdown_clock code significantly simpler. As for the music_tinker, that needs
to be rethought wholesale.
This removes `get_teams()`, `get_units()`, and `get_map()` from the display class. These only served as one of the many, many ways to access this data held by the display_context, and that shouldn't be the first-class responsibility of display. Instead, we either access them through the display_context pointer that display holds (whose getter has been renamed to `context()`) or through other more convenient paths (such as play_controller). The editor_display function `map()` has now taken up the mantle of `get_map()`, mostly because both `display::get_map()` and `editor_display::map()` are used, and the former outnumbered the latter.
Removed:
- debug_highlight et al. Unused, and we have the main "display coordinates" debug flag in the base class
- current_team_name. Only used in one place, clearer to just call team_name directly.
- get_terrain_on. Unimplemented
all_directions better reflects the purpose of the former. Also made it return a value,
since the only places that used it immediately assigned it to a local variable.
This function is implemented identically, though const, in display_context (the base class of game_board). We don't need the non-const game_board function here.
The current preferences handling is a mess:
* it's essentially a global config object that anything can modify in any way the caller wants, which is managed across multiple source files which have their own oddities and interdependencies.
* the general preferences has its own bit of SDL event handling and while I get the idea behind `events::sdl_handler` there's no reason to have SDL events handled in the preferences instead of just calling the relevant preferences setter for each event when it happens.
* the general preferences is where most of the preferences are handled and has its `base_manager` struct, which is part of the `manager` struct in the game preferences, which is then implicitly initialized as part of game_launcher's constructor.
* the editor preferences are the only preferences in a sub-namespace `preferences::editor` while all other preferences are just in the `preferences` namespace.
* the display, editor, and lobby preferences are all dependent on including the game preferences, the credentials are dependent on including the general preferences (but not the game preferences), the game preferences are dependent on including the general preferences, and the advanced preferences are entirely their own thing which is dependent on none of the other preference functionality and manages its own singleton.
* nothing checks whether the preferences file has actually been loaded before allowing values to be read from or written to the preferences config - if you attempt to get a value too early in wesnoth's initialization it will silently just give you whatever the default value for that preference happens to be.
With this there is instead a single access point (with exceptions handled via friend functions/classes), all predefined preferences are accessed via their own setter/getter, and all mainline preferences are defined in a single file (preference_list.hpp) so it's easily findable what preferences exist and where they're used. Having the list of all mainline preferences listed out also allows the lua preferences API to provide that full list rather than just the list of the preferences that have been set so far. Also it now checks for whether the location of the preferences file is known before attempting to load the preferences file and asserts if someone attempts to use the preferences too early.
- Used inline default values to reduce ctor mess
- Used a forwarded ctor for locator::value instead of duplicating them between the main class and the value class
- Removed trailing underscores from public struct members
- Removed const char* ctor to make locator use more explicit instead of relying on implicit conversions
- Moved parse_arguments to a value ctor since it's more appropriate there
- Added locator::clone to replace the ctor with optional modifications
This simplifies the drawing buffer implementation. Instead of storing textures (or lists of textures),
we now store a function which takes the rect of the specified hex. This function is responsible for
actually rendering textures. The upsides of this are several. First, it means the whole drawing buffer
interface is much cleaner, since it no longer has to worry about texture mods or anything of the sort
(alpha, color mod, etc). The drawing functions themselves can handle them as needed. Second, it means
the messy, hacky, surface-based unit HP/XP bar drawing code can be replaced with simple rectangles!
Also includes:
* The whiteboard arrows now use the drawing buffer. The complexities of render_image were not needed.
* display::render_image has been removed and made local to the unit frame drawing code, which it is
intended for.
* unit_drawer::scaled_to_zoom has been removed
* Added a point overload of display::scaled_to_zoom
* Merged drawing buffer calls which can now be logically handled together
* Removed drawing_buffer_key class in favor of a simple function to generate the key.
* Made display::add_submerge_ipf_mod a public static function
* Added display::get_location which combines get_location_x and get_location_y
* Avoid looping through invalidated hexes twice when rendering
* Refactored how hex debug aids are rendered
This has been megasquashed because it was a month-long mess of fixes
and reworks.
In summary:
* objects no-longer draw by hooking a DRAW event. In stead they
inherit from gui2::top_level_drawable, and implement its interface.
* the game display now renders to an offscreen buffer. This is used
to implement hardware scrolling, and to redraw after halos, floating
labels etc. move.
* halos, floating labels, tooltips, and a few more things are now
drawn on top of the game display, rather than as part of it. This
allows them to be updated independently without reading pixels
from the screen.
* surface restorers have been removed. Reading pixels from the screen
should now be unnecessary excepting two cases: (a) screenshots,
(b) background blur. Blur is cached, and screenshots are occasional.
* GUI2 widgets no longer keep track of dirty state. They are redrawn
as necessary. Most places which previously set dirty state now queue
a redraw in their part of the screen in stead.
* A consequence is that active translucency is enabled across all UI
elements, and the game display can (and does) continue to animate
while menus and dialogs are showing.
* performance is drastically increased for basically everything, most
notably map scrolling, floating text, and halos.
* CPU usage is drastically decreased. With animations disabled it is
essentially zero while nothing is moving.
* GPU usage is also minimal. The display is only flipped if something
is drawn.
Added new functions float_to_color() and color_multiply() for dealing
with uint8_t colour values directly, with an assumed mapping from
0-255 to 0.0-1.0 and back.
These were not being meaningfully used.
Also removed code flushing image caches when zoom level changes.
This is not necessary now that images are scaled on demand.
Many places are not completely converted, but rather just converting
a surface to a texture on the fly. This is likely to be very bad for
performance. However they can now be addressed one by one.
The display was being cleared from the loading thread, which should
never happen. I removed the call to clear it from the game_display
constructor, which shouldn't need to clear the display there anyway.
* controller_base::get_theme was removed and replaced with theme::get_theme_config. There was already a static map
of theme configs in the theme class, so no need to reinvent the wheel.
* Renamed theme::get_known_themes to theme::get_basic_theme_info
* Hidden themes will be included in the known_themes map. Filtering now happens in get_basic_theme_info, which now
has an additional `include_hidden` (false by default) argument.
* display::set_theme now takes the theme id instead of config
* editor_display no longer takes a theme_config/id argument and instead simply initializes its base class with the
"editor" theme directly.
* display now takes the theme id instead of config. game_display was adjusted accordingly