Commit Graph
351 Commits
Author SHA1 Message Date
staphen 71ccd415c5 Update gamepad motion state regardless of the active event handler 2023-04-16 08:49:30 +02:00
Gleb Mazovetskiy c858ab4d2c Fix some compilation warnings
also removes a couple of unused filesystem includes
2023-03-12 13:21:40 +00:00
Anders Jenbo 454efdc2c1 Re arange UI files
¨
2023-02-21 18:38:13 +01:00
Gleb Mazovetskiy f7580f188c Fix multiline DrawStringWithColors alignment
For center or right alignment, the lines past the first line were
aligned incorrectly. The alignment was based on the width of the
format string.
2023-02-14 09:42:14 +00:00
Gleb Mazovetskiy 1788d2f8ec Remove miniwin
Event handling code moved to `engine/events.{hpp,cpp}`.
2023-02-01 16:06:57 +00:00
c99f7cf644 Floating numbers (#5639)
Co-authored-by: qndel <[email protected]>
Co-authored-by: Stephen C. Wills <[email protected]>
2023-01-22 07:20:10 +01:00
DakkJaniels e5d96b2242 Removed ability to try and join incompatible ZeroTier games (#5648) 2023-01-12 15:27:33 +01:00
Anders Jenbo e50e21e0e4 Use outline for spell icon texts 2023-01-12 11:04:53 +01:00
obligaron 7a1f962e33 Settingsmenu: Create submenus for each category 2023-01-05 00:47:58 +01:00
qndel efaf334965 typos and code cleanup 2022-12-19 17:34:15 +01:00
staphen b66b6c611b Produce multiple controller button events for SDL_JOYHATMOTION events 2022-12-05 05:05:07 +01:00
Gleb Mazovetskiy 20e12dcc3a selhero: Fix heap-use-after-free
A popup-like error dialog in selhero resulted in a heap-use-after-free:

https://gist.github.com/glebm/f014bd87f066d2b79965b7c48bd8f6d7

This is because the popup's `Deinit()` freed the background art.

The fix is simply to not free the background art.
This is OK because the popup never has a background.

It used to load an empty background in the past just to load the
palette but luckily it no longer does (otherwise this would require more
work).

Also, fixes dialog rendering:

1. Fixes what is rendered behind the dialog.
2. Draws the mouse (if possible) regardless of whether the background is
   present.
3. Clears the screen if the background doesn't cover it completely.

Fixes #4195
2022-11-28 08:04:38 +01:00
Gleb Mazovetskiy 1e20a5721f Settings menu: Fix description clipping
Adjust description dimensions to make it fit exactly 3 lines for CJK.
Previously, the second line was clipped since we fixed the clipping.
2022-11-27 22:40:20 +00:00
staphen f17ea8db98 Implement settings menu for gamepad customization 2022-11-27 18:27:21 +01:00
Gleb Mazovetskiy 6dca019de2 Use function_ref instead of function
`function_ref` is a lightweight function pointer,
whereas `std::function` always involves a heap allocation.
2022-11-02 11:46:15 +00:00
Gleb Mazovetskiy 680ab5ec40 Overhaul backbuffer state handling
When rendering directly to the output buffer, we need to maintain the
state of what has been drawn and what needs redrawing per-buffer.

We previously tried to do it implicitly by checking `SDL_DOUBLEBUF` and
other flags. The previous implementation was broken in several
ways, resulting in rendering issues on devices that support 8-bit output
directly.

Changes this mechanism to explicitly maintain buffer state per output
buffer. The new mechanism doesn't require knowledge of the number of
buffers, and thus also works correctly with triple-buffering.

Fixes #5447
2022-11-01 02:43:24 +00:00
Gleb Mazovetskiy 0498d7d3a7 Fix compilation warnings 2022-10-29 13:41:23 +01:00
Gleb Mazovetskiy 41f43ea3f5 Support unpacked MPQs from devilutionx-mpq-tools
https://github.com/diasurgical/devilutionx-mpq-tools produces an unpacked MPQ
with all the graphics converted to CLX and the unused files removed.
This is primarily useful on RAM-constrained platforms, such as PS2,
because it eliminates the MPQ overhead.

Adds a build option to load from such unpacked directories instead of the MPQ.

These directories are searched for in the same locations
where the MPQs would be searched for otherwise.

Example directory layout:

* /usr/local/share/diasurgical/devilutionx/diabdat/ -- unpacked and converted diabdat.mpq
* /usr/local/share/diasurgical/devilutionx/hellfire/ -- unpacked and converted hellfire MPQs (all of them merged into 1 directory)
* /usr/local/share/diasurgical/devilutionx/fonts/ -- unpacked fonts.mpq
* /usr/local/share/diasurgical/devilutionx/pl/ -- unpacked pl.mpq

These directory structure is produced by calling `unpack_and_minify_mpq`
2022-10-11 18:00:57 +01:00
staphen f91d709f96 Fix rolling text in Support and Show Credits 2022-09-26 01:00:13 +02:00
staphen 6b7b0d3498 Fix error mapping keys when typing lowercase characters 2022-09-13 10:36:41 +02:00
Gleb Mazovetskiy f4827a0cb6 Replace default palette PCX files with PAL files
These PCX files were only used to load the default palette.
Replaces them with PAL files.
2022-08-24 03:22:15 +09:00
Gleb Mazovetskiy 4cf0053ece Set underlying type for all the enums
Reduces rg99 binary size by 3 KiB.
2022-08-11 01:43:54 +02:00
Gleb Mazovetskiy 99fcac822c Fix use-after-free in selhero 2022-08-10 10:40:57 +02:00
Gleb Mazovetskiy b881468c04 Difficulty indicator improvements (#5224)
* Difficulty indicator improvements

1. Clean up positioning code.
2. Do not show for non-save portraits.
3. Remove `vecDifficultyIndicators` - render the items on the fly instead
2022-08-09 13:22:52 +02:00
Gleb Mazovetskiy 623dd88fe7 Clean up selhero_Init 2022-08-09 10:13:31 +01:00
qndel ab6261bfe6 show difficulty indicator on multiplayer characters 2022-08-08 20:14:19 +02:00
Gleb Mazovetskiy 9b65eca49b Remove Art and related functions 2022-08-08 14:29:45 +01:00
Gleb Mazovetskiy f3e37781d9 ArtCursor: Art -> CLX 2022-08-08 14:29:45 +01:00
qndel ef5a4de227 typos + code cleanup 2022-08-07 20:28:43 +02:00
Gleb Mazovetskiy fcd163cac6 Remove unused DrawArt overload 2022-08-04 15:16:00 +02:00
qndel c7fcaf4dd1 fix error messages 2022-08-03 20:53:19 +02:00
Gleb Mazovetskiy 17a97450bc Convert assets to CLX
Converted using the following commands:

```
cd Packaging/resources/assets
pcx2clx --transparent-color 1 --num-sprites 256 fonts/*.pcx && rm fonts/*.pcx
pcx2clx --num-sprites 2 ui_art/dvl_but_sml.pcx && rm ui_art/dvl_but_sml.pcx
pcx2clx --transparent-color 1 data/hintbox.pcx data/hintboxbackground.pcx && rm data/hintbox.pcx data/hintboxbackground.pcx
pcx2clx --transparent-color 1 --num-sprites 6 data/hinticons.pcx && rm data/hinticons.pcx
pcx2clx --num-sprites 2 data/panel8buc.pcx data/dirtybuc.pcx data/dirtybucp.pcx && rm data/panel8buc.pcx data/dirtybuc.pcx data/dirtybucp.pcx
pcx2clx --transparent-color 1 data/healthbox.pcx && rm data/healthbox.pcx
pcx2clx --transparent-color 1 --num-sprites 6 data/resistance.pcx && rm data/resistance.pcx
pcx2clx --transparent-color 1 --num-sprites 5 data/monstertags.pcx && rm data/monstertags.pcx
pcx2clx --transparent-color 1 data/stash.pcx && rm data/stash.pcx
pcx2clx --transparent-color 1 --num-sprites 5 data/stashnavbtns.pcx && rm data/stashnavbtns.pcx
pcx2clx **/*.pcx && rm **/*.pcx
git checkout master -- ui_art/black_diablo.pcx ui_art/black_hellfire.pcx data/charbg.pcx data/talkbutton.pcx data/panel8bucp.pcx
rm ui_art/black_diablo.clx ui_art/black_hellfire.clx data/charbg.clx data/talkbutton.clx data/panel8bucp.clx
```
2022-08-03 16:37:04 +02:00
Gleb Mazovetskiy 961866e1c4 CLX: A new graphics format
The format is almost identical to CL2, except it uses the frame header
to store frame width and height instead of 5 32-line offsets.

This means we always have access to frame dimensions, so we can use it
as an on-disk format for our graphics as well.

Additionally, we may be able to optimize the rendering even more
in the future now that we have guaranteed knowledge of frame dimensions.
2022-08-03 02:38:55 +02:00
DakkJaniels 163ea36fa6 Convert ZT gamename to lower case (#5110) 2022-07-24 21:50:53 +02:00
Gleb Mazovetskiy 0cd035ef61 Load PCX as CL2
Similar to #5059, which converted CEL to CL2 at load time,
we now do the same for PCX.

Some size stats: https://gist.github.com/glebm/067bf1ec73f9d14514932cfe237e4e8e

Notably, fonts RAM usage is decreased by ~35%.
2022-07-20 22:58:15 +01:00
Gleb Mazovetskiy 8ca71272b8 Load all CEL as CL2
Convert CEL files to CL2 at load time. CL2 format is more efficient and is about as fast to render.

CEL vs CL2 sizes, on dLvl 5: https://gist.github.com/glebm/9bbdd76962abcd4fd2405ecd3379af97

Memory:

* Peak memory (while loading): -300 KiB
* Memory in-game (dLvl5): -700 KiB
* RG99 binary size: -15 KiB (1333096 -> 1317192)

Performance on rg99:

* On average, -1 FPS in town.
* Same FPS in dungeon (20 FPS on dLvl 1).
2022-07-19 10:59:35 +02:00
Gleb Mazovetskiy ea1087dfeb Use StrCat in a few more places
Now `fmt` is only used for more complex formatting and for translations.
2022-07-17 20:43:00 +02:00
Gleb Mazovetskiy a4ac41cece Replace DVL_VK virtual key codes with SDLK 2022-07-17 10:00:06 +01:00
Gleb Mazovetskiy f9f6949af2 Clean up effects_play_sound, gfnSoundFunction 2022-07-16 10:59:40 +01:00
Gleb Mazovetskiy 643c707c55 Remove strncmp 2022-07-16 10:59:40 +01:00
obligaron ebfb519ee0 Rename gbQuietMode to HeadlessMode 2022-07-13 18:54:36 +02:00
Anders Jenbo 3ae834148a Split event handeling from general miniwin features 2022-07-10 21:13:39 +02:00
Anders Jenbo 2d21fc372e Remove more miniwin code 2022-07-10 21:13:39 +02:00
Gleb Mazovetskiy 197e1180b2 Add StrCat and StrAppend
Adds simple string / integer concatenation functions.

Many of the uses of `fmt::format` are simply concatenation
of a few strings and integers.

`StrCat` is an easier-to-read alternative to such uses of `fmt`.
2022-07-10 06:14:58 +02:00
Cesar Canassa e538acb248 📝 Fixes Doxygen warnings (#4904) 2022-07-07 12:51:24 +02:00
Mikołaj Piróg dda0b96ea5 Remove #defines in player.h and add constexpr where applicable (#4896)
* Change defines to constexpr int in player.h

* Add const or constexpr to player.h/cpp where applicable

* Update tests with changed names of player constatns

* remove unecessary variable
2022-07-05 17:25:23 +02:00
Stephen C. Wills 4584b41d69 Fix errors rendering progress dialog (#4878) 2022-07-03 20:31:44 +02:00
Gleb Mazovetskiy ad7ca97ae1 Fix black background palette (#4831)
Diablo and Hellfire have different palettes in `ui_art\black.pcx`.

We now ship our own tiny `black.pcx` that takes priority over the
other ones. This `black.pcx` had the Diablo palette which resulted in an
incorrect palette in the Settings screen.

Split our own `black.pcx` file into `black_diablo.pcx` and
`black_hellfire.pcx` and load the correct one depending on the mode.
2022-07-01 18:17:18 +02:00
Gleb Mazovetskiy 7e582a5840 DiabloUi: Render focus indicators as PCX
They're slightly larger as PCX then CEL but are tiny overall.

This was the last use of `LoadPcxAssetAsCel`.
2022-07-01 16:21:44 +01:00
Gleb Mazovetskiy 0c7e36e81a DiabloUI: Clean up portrait loading
1. Load portraits as PCX (~30% smaller).
2. Simplify the portrait override logic.
2022-07-01 16:15:40 +01:00