Commit graph

38 commits

Author SHA1 Message Date
Charles Dang
ee35f6ac9a Cleaned up various surface-related backend things
* Removed create_neutral_surface in favor of a surface ctor that takes w/h dimensions.

* Removed make_neutral_surface in favor of a surface::make_neutral function. Most usecases of this were
  to make a copy of a surface anyway, so I added a new surface::clone function

* Moved the pixel format validation and conversion to the surface class. Now *all* surfaces should be
  guaranteed to be in the 'neutral' format. Any new surface that is created (with clone() or the dimension
  ctor will be in that format, and any time a raw SDL_Surface* ptr is assigned, it is also converted. This
  applies both to the ctor and assignment operators.

* Removed create_compatible_surface. All surfaces should be compatible in the first place.

* Removed surface::assign was in favor of simple assignment operators. The existing assignment operators
  already just called assign().

* Removed surface::null in favor of the implicit SDL_Surface* conversion operator for consistency. We were
  already using null and implicit pointer bool conversion, so I decided to go with the latter. I was going
  to add an operator bool(), but it was ambiguous in surface-to-surface comparisons.
2019-07-22 15:39:00 +11:00
jostephd
25957e3f63
UI: Highlight enemy units in "Show Enemy Moves" mode (#3961)
Fixes #1989
2019-03-05 17:09:13 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
Charles Dang
19e3afb463 Convert C-style casts to static_cast
(cherry-picked from commit 0dc5656c32)
2018-10-07 03:21:02 +00:00
Charles Dang
2b65a8c5c8 Units: refactor display_context parameter out of ability functions
This was essentially only needed for the affects_side() helper. THAT'S IT. All this code just for
one single line... Anyway...

Utilized the display singleton's display_context getter instead. This also means fewer explicit
uses of resources::gameboard as the display_context object, meaning more compatibility with the
editor (not that that's relevant for most of the changed usecases, such as the AI, but it does
affect unit::get_abilities, which might be useful there in the future).

This also removes the display_context parameter from unit::invisible() since it was only passed to
unit::get_ability_bool().

unit::is_visible_to_team() also had its display_context parameter removed. It was used once as an
argument for invisible() and the other case was replaced with display::get_map().

(cherry-picked from commit 7e442cbb54)
2018-10-07 03:19:34 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f693)
2018-10-07 03:17:59 +00:00
gfgtdf
ff31a99aa2
add bar_offset_x/y to [unit_type]
this should probably be opimized later so that it does not need the config lookup on each redraw, but that can be done 1.13.12
2018-03-17 19:47:30 +01:00
Charles Dang
950a156712 Addressed most of the remaining whitespace issues from #2613
[ci skip]
2018-03-11 14:59:37 +11:00
Charles Dang
61cd444fa1 Units: range-for 2018-03-06 09:48:48 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
d09ad24037 Used standard C++ fixed-width integer types instead of SDL-provided ones
More consistent this way. It's very unlikely the SDL defines would clash with the standard
C++ ones, even in SDL-related code.
2017-12-06 01:31:59 +11:00
Charles Dang
ff5d68f9f5 Some refactoring of team color data handling
These changes cover areas from PR #2101, excluding the removal of the numeric ID color ranges.
That can't be done yet (it breaks things).

This also excludes any changes to the connect_engine color handling. That needs to be refactored
separately. Despite the fact that it's done very similar to the new get_side_color_id function,
I need to deal with the fact that every side_engine member in the connect engine keeps a copy of
the default color options.

* Added a general-purpose function to extract color data from a config.
* Refactored the team class's general get-side's-color-data function so it always returns a color
  ID instead of falling back on a number.
* Deployed this change for the leader image coloring in the save_index; said coloring is now always
  done by ID.
* Save color data by ID in team_info instead of using the side number if no color was provided.
* Renamed get_side_color_index to get_side_color_id to better reflect its purpose.
2017-10-26 09:27:50 +11:00
Charles Dang
ec042a4f4e Use shared_ptr::reset for clearing halo handlers 2017-08-12 18:52:47 +11:00
Charles Dang
078a4f6a64 Renamed fill_rect fill_surface_rect to better distinguish it 2017-05-26 16:28:48 +11:00
Charles Dang
5e6e8eab6f Made energy_bar_rects static in unit_drawer file (superior version of 1ff1b7fdd)
I reverted the aforementioned commit after being informed it would be inferior, performance-wise.
However, this should solve that as the map is no longer constantly recreated.

This also addresses some issues I had with the original commit where I had to make some member
functions non-const.
2017-05-17 22:40:35 +11:00
Charles Dang
4479682469 Convert uses of create_rect to aggregate initialization when possible
This only includes cases where this can be done without triggering warnings about narrowing conversion.
Also includes cleanups of sdl/rect.hpp includes.
2017-05-17 21:16:57 +11:00
Wedge009
713995276b Reduce invisible units' transparency (#987)
Units are rendered at 0.5 alpha when they are invisible (for example, Elvish Avengers' Ambush ability). An issue arises with the Shadow (and Nightgaunt) ghost unit which has the Nightstalker ability allowing it to be invisible at night time - in combination with its fluctuating alpha animation, it can be quite hard for the player to see at night time (https://gna.org/bugs/?14503). So this change slightly increases the alpha level of invisible units from 0.5 to 0.6.
2017-05-04 02:11:10 -04:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00
Charles Dang
e1a579da51 Deployed std::map::emplace en-masse 2017-04-09 15:40:13 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Charles Dang
d10c4e7a0b Revert "Made the unit_drawer own its bar rect map instead of keeping it in the display singleton"
This reverts commit 1ff1b7fdd8. I've been informed this is inferior, performance-wise.
2017-03-08 19:18:14 +11:00
Charles Dang
1ff1b7fdd8 Made the unit_drawer own its bar rect map instead of keeping it in the display singleton 2017-03-08 19:00:19 +11:00
Charles Dang
42f087abb3 Extensive cleanup of unit animation frame code
The majority of which consists of code formatting, but also a few small semantic changes (tristate -> boost::tribool, etc).
2017-03-02 11:45:24 +11:00
Charles Dang
b97a20b059 Split SDL_Surface wrapper class and related helper struts into their own file
This (should) allow sdl/utils.hpp to be modified without a huge rebuild, since a number
of widely used headers included that file simply for the surface class type.
2016-12-10 22:36:31 +11:00
Charles Dang
f2d730bd86 Convert unit animation code to use color_t
boost::optional was used for certain colors in frame.*pp since there isn't a good way to convert
a color_t to an "is present" bool.
2016-12-07 11:10:30 +11:00
Celtic Minstrel
e7e5ca5fa2 Fix Travis 2016-12-01 15:06:25 +02:00
Charles Dang
4b3862493f Convert all usecases of SDL_Color to color_t 2016-11-30 17:59:30 +11:00
Charles Dang
a60433356d Refactored out display::rgb, red, blue, green, and blend_rgb 2016-11-30 14:46:22 +11:00
Celtic Minstrel
b74afeff73 Rename terrain classes to avoid t_ prefix 2016-11-09 01:13:17 -05: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
Jyrki Vesterinen
e82fc498ac Remove the map parameter from the unit::is_visible_to_team() function
Now when the function receives the entire display_context and can get the
map from there, passing the map separately is unnecessary.
2016-09-06 23:03:10 +03:00
Jyrki Vesterinen
7573678201 Fix crash on placing a unit with the scenario editor
The unit::get_ability_bool() function accessed resources::gameboard that
is not set in the editor. Now the function receives the display context
as a parameter instead.

I also fixed two crashes on editor startup in MSVC debug builds (both
caused by indexing the teams vector when there aren't any teams), and the
GUI2 unit list dialog showing wrong status icons.
2016-09-06 23:03:09 +03:00
Charles Dang
6100bac258 Refactored out some uses of snprintf in getting unit ellipses 2016-08-23 13:54:59 +11:00
Celtic Minstrel
2d7d6a0dde Fix crash when trying to draw a unit with no image 2016-07-18 02:39:12 -04:00
Jyrki Vesterinen
0bc068113a Fix bug #23712: Mage of Light halo not drawing correctly
The halo is recreated when the mage starts to move, and it's initially
placed in the top-left corner of the screen. On the next frame the game
corrects its position. Correcting the position clears the list of hexes the
halo overlaps, which essentially means "the overlapped hexes aren't known,
update them when the halo is redrawn". However, the game also uses the list
of overlapped hexes to determine when the halo should be invalidated, and
thus redrawn: because the list was empty, the halo was never invalidated,
and it stayed at the top-left corner.

Fixed by placing the halo in the right position to begin with. This commit
includes my previous fixes as well, though, because the code was simply
incorrect before (even if it doesn't break anything any more).
2016-06-26 22:26:20 +03: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
Celtic Minstrel
bc711f5f43 Consolidate related files into subdirectories 2016-03-20 16:20:09 -04:00
Renamed from src/unit_drawer.cpp (Browse further)