Commit graph

463 commits

Author SHA1 Message Date
Anders Jenbo
a19e7b2a3b Remove some more use of miniwin 2021-07-17 23:54:13 +02:00
obligaron
1956c6a1c2
Fix some 64bit warnings 2021-07-17 18:30:39 +02:00
Anders Jenbo
77b72da276 ♻️Use monster by reference when possible 2021-07-14 20:22:35 -07:00
Anders Jenbo
352a0ca510 Place local symbols in an anonymous namespace 2021-07-09 16:54:01 -07:00
Anders Jenbo
bc51e1616d 🎨 Apply clang-tidy 2021-07-08 08:14:03 -07:00
Anders Jenbo
20262e4569 🚚 Move local symbols in to anon namespace 2021-07-08 08:14:03 -07:00
Anders Jenbo
9ebdb6db69 General clean up 2021-07-08 03:30:25 -07:00
Anders Jenbo
9b8bf92575 Rename quest globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
96bf75b502 Rename player globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
07ad083fda Rename monster globals 2021-07-08 02:01:14 -07:00
Anders Jenbo
cb564a2d54 Clean up A-D 2021-07-04 05:25:37 -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
Anders Jenbo
4eabc6024b Apply various cleanups via Android Studio 2021-07-03 18:27:17 -07:00
Andrew James
3508aa6d3d
Align Life/Mana flask drawing routines (#2291)
* Clamp hpPer as a sanity check
* Refactor update mana routines in control.cpp to use PlayerStruct::UpdateManaPercentage
* Remove unnecessary calls to UpdateHP/ManaPercentage
* Unify logic that draws the flasks into a single internal function
* Fix style violations
* Remove unnecessary save/loads of hp/manaPer

The way this variable is used expects a value in this range and it gets clamped again anyway, but this makes the code more similar to the manaPer logic for future refactoring

Identical logic in use, the checks to see if the values are negative can be accomplished using clamp and the same divide by zero guard. I'll combine the two attributes in a near future commit.

control_update_life_mana is called during the game loop before any of the drawing functions so hpPer/manaPer are calculated based on the latest current/max of their respective attributes every frame.

There's no need to do the calculation again in the draw routines. (There's also no need to calculate this every frame but that's going to take a bit to untangle.)
2021-07-03 18:06:24 +02:00
Gleb Mazovetskiy
cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
Anders Jenbo
d9e0658643 Clang-tidy: basic naming 2021-07-02 22:55:01 +02:00
ephphatha
3f69faaecf Refactor DrawLifeFlask to minimise bounds checks, add comments 2021-07-01 09:34:42 -07:00
ephphatha
58f3ca9ba3 Refactor player hp percentage calculation to avoid C4244 warnings 2021-07-01 09:34:42 -07:00
Juliano Leal Goncalves
cbb84199c2 ♻️ Replace Point addition with 'Point + Displacement' 2021-06-28 20:37:44 -07:00
Juliano Leal Goncalves
0441ffc2f4 ♻️ Move 'fromDirection' from 'Point' type to 'Displacement' type 2021-06-28 20:37:44 -07:00
Anders Jenbo
e7f0ce2764 Apply cleanups to codec, control, and some of cursor 2021-06-27 07:47:15 -07:00
Juliano Leal Goncalves
a37311ddc4 ♻️ Leverage 'Point.Contains' for bound checks related to character buttons 2021-06-27 16:37:59 +02:00
Juliano Leal Goncalves
fd9f2099d0 ♻️ Leverage 'Point' to represent mouse position 2021-06-27 16:37:59 +02:00
Anders Jenbo
48113d064a Clang-tidy: readability-redundant-declaration 2021-06-27 00:56:08 +02:00
Anders Jenbo
79c9078fa1 ♻️Clean up type sizes 2021-06-24 15:11:09 -07: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
Anders Jenbo
ee7b32d8f6 Player by reference part 3 2021-06-24 00:53:09 +02:00
Gleb Mazovetskiy
e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
Juliano Leal Goncalves
25eaac78c1 ♻️ Leverage 'Size' to represent a 'Rectangle's width/height 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
e3ea6a9042 ♻️ Leverage 'Point' to represent a 'Rectangle's position 2021-06-20 18:27:45 -07:00
Juliano Leal Goncalves
ff147f9280 🚚 Rename 'RECT32' to 'Rectangle' to match naming style of other core structs 2021-06-20 18:27:45 -07:00
Gleb Mazovetskiy
982260d94e Clip control.cpp draw calls
No longer crashes there when running at a resolution smaller than
640x480
2021-06-16 03:12:54 +02:00
Kalebe Alves
118efe8e6d
Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
Gleb Mazovetskiy
dd3ea66fa2 ♻️ Split getTextColor(bool) into 2 functions
This is a bit more readable than using a bool argument.
2021-05-28 13:38:36 +02:00
qndel
2f3cf65b27 cleanup getTextColor 2021-05-26 15:58:14 +02:00
Anders Jenbo
8a7ec56d3a Player by reference part 2
This mostly change player to be by reference instead of by index.
But additionally it does stript checks for gold in the belt, move some
value types to the initialization and short circute a few functiongs.
2021-05-24 21:00:32 +02:00
Anders Jenbo
6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Jmgr
0e7ada15fc Apply new format to ngexttext translations 2021-05-21 01:02:45 +02:00
Jmgr
bbd39aa513 Replace sprintfs with strcpy for translatable strings 2021-05-21 01:02:45 +02:00
Jmgr
6e85cde978 Update format strings 2021-05-21 01:02:45 +02:00
Jmgr
0c27e756f7 Add fmt::format 2021-05-21 01:02:45 +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
Anders Jenbo
a11bc61ea8 ♻️Render spellbook text via DrawString 2021-05-17 03:04:56 +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
34744c068f ♻️Consitantly use %i and not %d 2021-05-15 14:17:52 +02:00
arcas
6502a3ca4d
Adding resources for translation (#1973) 2021-05-15 14:12:28 +02:00
Anders Jenbo
7667880de4 🐛 Implement letter spacing in new font rendering
Fixes #1950
2021-05-13 21:52:44 +02:00
Anders Jenbo
0c2042fa52 ♻️ Player by reference
Update Source/items.cpp
Update Source/lighting.cpp
Update Source/pack.cpp
asd


ads


as
2021-05-13 01:47:46 +02:00