Commit graph

480 commits

Author SHA1 Message Date
vladtepesch
0e56e52c75
fixes casting level 0 spell says "not enough mana" (#2568) 2021-08-11 19:52:00 +00:00
obligaron
8dbe16d4f6 Introduce GetSpellListItems 2021-08-11 02:44:51 +02:00
obligaron
95daecc1bb Introduce GetSpellListSelection and remove selection game logic from DrawSpellList 2021-08-11 02:44:51 +02:00
BC Ko
0a4361d5fc cleanup manual value clamping: control.cpp 2021-08-10 20:20:27 +02:00
Aaron Sun
6701b8a989 Fix attribute up (+) button doesn't work in special case
1) Open quest panel
2) Open character panel by click level up (+) button
2021-08-08 14:28:23 +02:00
Aaron Sun
aef812fb5a Modify the calculation of panel position
left/center combination is used, but panel distance is limited
2021-08-08 02:08:02 +02:00
Anders Jenbo
8df8b940c4
Handle some clang-tidy issues 2021-08-07 16:30:14 +02:00
Aaron Sun
3ee90ca629 Add options for sub-panel alignment 2021-08-07 16:09:32 +02:00
Anders Jenbo
90960f0c14 Remove dead code 2021-08-07 00:36:38 +02:00
4aron5un
4c8210df21
Center the sub-panels (Quest, Character, Spell and Inventory) (#2498) 2021-08-05 21:27:07 +02:00
Vladimir Olteanu
b17ff04ee2 Use string_view in DrawString and friends 2021-08-05 01:40:43 +02:00
qndel
169f980038 ranged/magic formulas 2021-08-04 23:55:44 +02:00
qndel
bd5e30db52 replace armor formula 2021-08-04 23:55:44 +02:00
Anders Jenbo
d523fc1e81 Cleanups 2021-08-02 10:12:40 +02:00
ephphatha
0575716eac Rename UiFlags members to group related options 2021-07-31 20:22:40 +02:00
ephphatha
4ad53232a0 Convert the UiFlags enum to a scoped enum type
Replace operator&& with named function
2021-07-31 20:22:40 +02:00
Anders Jenbo
a2bed56061 Clean up some variables in control.cpp 2021-07-18 05:16:02 +02:00
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