Commit graph

54 commits

Author SHA1 Message Date
ephphatha
b680e3fef1 Align end comment markers for doxygen comments
Including a bunch from previous PRs (since I was responsible for the broken formatting for most 😓)
2021-07-09 18:00:15 +02:00
Anders Jenbo
2ca6e37c46 Clean up sub folders using clang-tidy/Android Studio 2021-07-08 03:30:25 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Gleb Mazovetskiy
55464eec78 Fix -Wmissing-braces
Fixes warnings such as this one:

```
../../../../../../Source/engine/render/text_render.hpp:83:33: warning: suggest braces around initialization of subobject [-Wmissing-braces]
        return DrawString(out, text, { position.x, position.y, out.w() - position.x, 0 }, flags, spacing, lineHeight, drawTextCursor);
                                       ^~~~~~~~~~~~~~~~~~~~~~
```
2021-07-03 19:08:45 -07:00
Gleb Mazovetskiy
cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
qndel
a1710ff51e
pass item to CelDrawItem (#2265)
pass item to CelDrawItem
2021-06-29 18:09:54 +02:00
Anders Jenbo
8e07ef8fe5 Clang-tidy: misc-unused-parameters 2021-06-27 17:34:32 +02:00
Anders Jenbo
2bdb6caa07
Cleanup majority of remaning implicit bool conversions (#2234) 2021-06-26 21:05:45 +02:00
Anders Jenbo
2417d3d333 🔥 Remove unused code 2021-06-25 13:22:08 +02:00
Anders Jenbo
af254601d6 ♻️ Apply clang-tidy to engine 2021-06-25 13:22:08 +02:00
Andrew James
60a47caf1b
Refactor Draw* functions to use Rectangle and Point types
Added overload for DrawString taking a Point to avoid creating a rect for callers which only use position. This also documents the way DrawString operates when passed a clipping rectangle with a dimension of 0.
As part of this overload removed the logic for 0 width regions from DrawString. This does change the behaviour of the Rectangle version if called with a rect with width 0, all callers using that behaviour have been updated in this commit.

Using Rectangle/Size allowed simplifying the logic for certain calls where they could use DrawText alignment flags, previously this was manually aligning by calculating dimensions and offsetting the position. This also fixes #2169

Also includes a few instances where a temporary buffer was used to set the text to be drawn with unbounded sprintf calls, replaced those with snprintf as is recommended in modern C applications. Moving to C++ strings would be good in a future refactor.
2021-06-24 01:36:06 +02:00
Gleb Mazovetskiy
14218080b6 🚚 engine.h: Extract CelGetFrame and friends 2021-06-21 02:34:28 -07:00
Gleb Mazovetskiy
e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
Gleb Mazovetskiy
f9f301b054 🚚 engine.h: Extract Point, Direction, clamp
`engine.h` is getting quite bloated. Moves this code to their own files.
2021-06-21 01:36:20 -07:00
ephphatha
b478d8295c Remove dead code, FreeText() is never called
Given the program already lets the destructors get called naturally there's no need to explicitly call this function. Even if it was desirable to re-init the font data the old instances will be destroyed when the new instance is assigned to the optional.
2021-06-19 08:47:47 -07:00
Chance4us
608c231f46
Draw black drop shadow for automap (#2090) 2021-05-31 16:09:55 +02:00
Kalebe Alves
118efe8e6d
Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
Kalebe Alves
0461529176 Move byte from engine.h 2021-05-27 16:04:27 +02:00
qndel
b1d74d2791
alt highlighting (#2060) 2021-05-25 23:47:29 +02:00
Anders Jenbo
6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Gleb Mazovetskiy
b76f7656f3 🧹 LoadArt: BYTE -> uint8_t
The change in include order necessitated a couple of other minor
cleanups, one in stubs.h and one in sdl2_to_1_2_backports.h
2021-05-23 18:45:01 +02:00
qndel
69b903743a fix typos 2021-05-23 05:52:52 +02:00
qndel
faae9a65c7
fix typos (#2038) 2021-05-23 03:57:47 +02:00
Gleb Mazovetskiy
bb95e0c337 cl2_render: Use memset when rendering outline
A minor cleanup that replaces the for-loop rendering for a fill run
with memsets.
2021-05-22 15:55:51 +02:00
Anders Jenbo
6acb49bea4 Render quest and menu text using common text rendering 2021-05-21 04:23:49 +02:00
Anders Jenbo
4c6ddc79a1 Clean up text render 2021-05-19 14:09:33 +02:00
Anders Jenbo
a03a2c2634 Render chat panel using common text rendering 2021-05-19 14:09:33 +02:00
Anders Jenbo
d723ebce1a Render help text using common text rendering 2021-05-19 14:09:33 +02:00
thebigMuh
7fbcfeb35c Adding text rendering flag to adjust spacing to fit horizontally
Now also works for multiline strings
2021-05-16 00:55:20 +02:00
Anders Jenbo
18aa04fa4f ♻️Use common text rendering for store menus 2021-05-14 19:11:43 +02:00
qndel
610d5319bd
swap if in drawing inventory items (#1968) 2021-05-14 12:50:32 +02:00
qndel
89c40eaa7b
inventory items rendering cleanup (#1938) 2021-05-14 12:46:16 +02:00
Gleb Mazovetskiy
8ac9047b4f 🧹 Clean up CEL outline clipping
A simpler structure based on the CL2 implementation.
2021-05-13 23:41:50 +02:00
Anders Jenbo
7667880de4 🐛 Implement letter spacing in new font rendering
Fixes #1950
2021-05-13 21:52:44 +02:00
Gleb Mazovetskiy
29a488738e 🔥 Mark core CL2 and CEL functions as inline hot 2021-05-13 02:22:38 +02:00
Gleb Mazovetskiy
f624b9788c 🔥 Mark dun_render functions as hot 2021-05-13 01:54:27 +02:00
Gleb Mazovetskiy
4d10642b3d 🧹 Add and use a DVL_ALWAYS_INLINE macro
Also moves attribute macros out of miniwin into a new header.
2021-05-13 01:54:27 +02:00
Gleb Mazovetskiy
e53a79259d 🐞 CL2 outline: Fix left clip 2021-05-13 01:01:45 +02:00
Gleb Mazovetskiy
537e056111 🐞 CL2 outline: Skip color index 0
Fixes a regression introduced in #1934
2021-05-12 08:19:19 +02:00
Gleb Mazovetskiy
fb27ee3907 💨 dun_render.cpp: Faster RenderLine
Turns RenderLine line branches into template parameters, allowing the
compiler to eliminate the branches and also fully inline it.

Example FPS change

* In dungeon: 1450 -> 1530
* In town: 1655 -> 1700

Also splits RenderLine into 3 functions

Easier to read and also gives more useful profiling.
Apparently the most time is spent in `RenderLineOpaque`.

Also, mark them `inline` because that apparently hints GCC to inline
the function (in a later refactoring we can introduce attribute
always_inline instead where supported).
2021-05-12 08:17:14 +02:00
Gleb Mazovetskiy
64ad9aeacf 🎉 cl2_render.cpp: Clip the outline 2021-05-11 07:57:08 +02:00
Anders Jenbo
e3c0c0a216 Fix some compiler warnings 2021-05-10 23:17:43 +02:00
Gleb Mazovetskiy
99dc016ec1 🧹 cel_render: Move internal functions to anon ns 2021-05-10 12:35:55 +02:00
Gleb Mazovetskiy
1838eb43f2 🎉 cl2_render.cpp: Clip the drawing functions
Clips all the drawing functions except the outline one.

Example FPS gain in a dungeon: 1454 -> 1488
2021-05-09 05:48:48 +02:00
Gleb Mazovetskiy
ad18ecc21b 🎉 cel_render.cpp: Clip stippled transparency
Example FPS change: 1336 -> 1424
2021-05-09 05:31:41 +02:00
Gleb Mazovetskiy
be7880c4db 🎉 cel_render.cpp: Clip outline
Clips `CelBlitOutlineTo` to the output buffer.

The templated implementation means that this compiles to many
case-specific functions with near-branchless inner loops.

Increases binary size by 92 KiB.
2021-05-09 05:31:41 +02:00
Anders Jenbo
0b3d1c68fa Precompute font color tables 2021-05-08 18:48:19 +02:00
Anders Jenbo
68923c6c33 Generic game text render function
This should gradually replace all the direct rendering of game texts
throughout the code. The interface is made to closly mirror that of the
art fonts as that is what will eventually be used for rendering Unicode
fonts both in the menus and ingame.

fixup!  Generic game text render function
2021-05-08 18:48:19 +02:00
Anders Jenbo
bcbaeba2f0 📝 Correct file header 2021-05-08 18:48:19 +02:00
Gleb Mazovetskiy
710ddb9af6 ♻️ Make SetPixel a method 2021-05-07 01:02:03 +02:00