Commit Graph

554 Commits

Author SHA1 Message Date
Gunter Labes
07ef83131a
Make function properly local and fix variable names 2025-03-15 21:13:48 +01:00
Gunter Labes
470c0b8b0a
Remove badly named variable 2025-03-15 21:13:39 +01:00
pentarctagon
d674e9f462 automatic copyright update 2025-02-17 12:59:51 -06:00
ForestDragon
93509c8499
Implement Reachmap Color and Opacity Options (#9877)
Co-authored-by: Descacharrado <Luis_koopa@hotmail.com>
Co-authored-by: Gunter Labes <soliton@wesnoth.org>
Co-authored-by: Charles Dang <exodia339@gmail.com>
2025-02-14 23:39:49 -05:00
Descacharrado
98aa84ff41
Polishing the visual highlighting of reachable hexes (#9542) 2025-02-02 13:48:10 -05:00
JJ Marr
6999b294d5 Use std::move wherever possible 2024-12-01 23:19:53 -05:00
Charles Dang
4ccfca6b1d Game Display: check for teams before refreshing reports (fixes #9609)
Regression from 7fa4fe483c
2024-11-28 22:13:43 -05:00
Charles Dang
12fa8f2844 Use standard chrono types consistently throughout the codebase
* 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.
2024-11-07 11:10:13 -05:00
Charles Dang
0e8edd12e4 Remove display::get_location_x|y 2024-10-25 02:41:59 -04:00
Charles Dang
c5891ef7fe Display: clean up exclusive draw stuff 2024-10-20 01:54:37 -04:00
Charles Dang
6d40872de0
Display: remove display_context wrapper functions (#9481)
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.
2024-10-19 21:38:18 -04:00
Charles Dang
fc514ccefb Game Display: clean up unused/unnecessary functions
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
2024-10-18 14:19:37 -04:00
Descacharrado
52e132648d
Highlight reachable hexes instead of darkening unreachable hexes (#9292) 2024-10-17 23:23:53 -04:00
Charles Dang
f04e19934f Map Location: rename default_dirs and get_opposite_dir
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.
2024-10-10 22:57:23 -04:00
Charles Dang
f4fda31707 Map Location: convert direction to a scoped enum 2024-10-10 22:57:23 -04:00
Charles Dang
500e937ac9 Display: use new team getters internally
currentTeam_ is what viewing_team_index returns
2024-09-02 12:37:41 -04:00
Charles Dang
4c6580250a Clean up more unnecessary uses of display::viewing_side 2024-09-02 12:37:41 -04:00
Charles Dang
0940b7451b Display: add back [viewing|playing]_team as actual team reference getters
Cleaned up redundant getters in other classes that served the same purpose.
2024-09-02 12:37:41 -04:00
Charles Dang
58472054fb Display: rename [viewing|playing]_team to [viewing|playing]_index 2024-09-02 12:37:41 -04:00
Charles Dang
7fa4fe483c Remove display::team_valid
It's already checked when it's set
2024-09-02 12:37:41 -04:00
Charles Dang
03cf5e64ce Revert "Game Display: don't use resources::tod_manager"
This reverts commit c21b049d52.
2024-08-31 17:15:06 -04:00
Charles Dang
c21b049d52 Game Display: don't use resources::tod_manager 2024-08-31 15:24:21 -04:00
Charles Dang
28555f362f Game Display: avoid gameboard global ptr for get_visible_unit
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.
2024-08-31 05:08:18 -04:00
Charles Dang
d762bea734 Split drawing_layer into its own file, make scoped enum 2024-08-08 02:14:22 -04:00
pentarctagon
9821e2037b macroify some preferences code 2024-08-07 21:31:11 -05:00
Pentarctagon
971073055e
Refactor the preferences into a proper singleton. (#8930)
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.
2024-06-09 11:34:09 -05:00
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Gunter Labes
34df9d6ca8
Revert "Game Display: make first_turn a static local to the only function that uses it"
This reverts commit cc7204f66e.
2023-07-26 19:18:05 +02:00
Charles Dang
cca82c4c3a Cleaned up implementation of image::locator
- 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
2023-05-27 19:13:32 -04:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Charles Dang
c6932e8133 Refactored gamemap drawing
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
2022-10-04 04:17:53 -04:00
Pentarctagon
72a1c801c0 Log exception type when doing catch(...). 2022-08-25 22:22:22 -05:00
Tommy
9cd5fd1249 display: Replace pre_draw etc. subclass hooks with TLD overrides
pre_draw() -> update() override
post_draw() -> render() override
refresh_reports() -> layout() override
2022-07-31 16:47:26 +12:00
Tommy
26072b7ab4 Automatically invalidate all map tiles when updating time-of-day 2022-07-29 16:52:44 +12:00
Tommy
3bf2339c07 display: Stop using surfaces for tod_hex_mask
ToD mask fade is probably better now, but needs testing as it isn't
used in mainline.
2022-07-22 15:07:59 +12:00
Tommy
06254e5581 Mega draw manager implementation
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.
2022-07-13 13:34:01 +12:00
Tommy
0fbc12ea01 Remove largely incorrect usage of floating_to_fixed_point()
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.
2022-07-02 17:12:00 +12:00
Tommy
827ae6568a Remove some done and trivial todos. 2022-07-01 15:06:25 +12:00
Tommy
132a45c52f sdl/rect: Move fill_surface_rect to sdl/utils.hpp
And then have to clean up over a dozen files that were relying on
sdl/rect.hpp including sdl/utils.hpp and various other side effects.
2022-06-29 13:13:15 +12:00
Tommy
2d7e0a074d Merge PR #5163 (halo animation freezing fix) 2022-06-28 14:32:39 +12:00
Tommy
738392069d Fix a whole bunch of bad indentation.
Mostly spaces where tabs should have been used.
2022-06-25 15:24:03 +12:00
Tommy
bd8eefbcaf Scale floating effect text (such as damage numbers) by zoom. 2022-06-14 14:44:11 +12:00
Tommy
eb040fd639 remove image::BRIGHTENED and brightened image cache.
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.
2022-06-11 05:56:07 +12:00
Tommy
46750666b2 Remove all usages of SCALED_TO_HEX.
Images are scaled when drawn.
2022-06-11 05:56:07 +12:00
Tommy
05d36f77aa Get map screenshots working again. 2022-06-10 19:06:56 +12:00
Tommy
23947d36fe display: Convert draw buffer to use textures not surfaces.
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.
2022-06-10 16:48:29 +12:00
Tommy
0ebef58f9a Potential fix for segfault while loading campaign.
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.
2022-04-24 13:21:49 +12:00
Charles Dang
dfc19676bb Refactored display-class theme initialization
* 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
2022-03-31 13:55:11 -04:00
Pentarctagon
d8fcda4960
Give better names. 2022-03-29 22:22:39 -05:00