40 Commits
Author SHA1 Message Date
Gleb Mazovetskiy 88f706e0d1 SDL3: Add some backports / compat helpers 2025-10-10 00:49:44 +01:00
Gleb Mazovetskiy 1bbe8bfe08 SDL3: Even more migration 2025-10-09 01:28:37 +01:00
Anders Jenbo df82616df1 clang-tidy: auto fix headers for DiabloUI 2025-08-16 06:20:40 +02:00
Anders Jenbo 1c76897f2c Apply simple const rules using clang-tidy 2025-08-16 01:21:36 +02:00
Gleb Mazovetskiy 903f0a8181 Simplify palette handling
Gets rid of `orig_palette`, we now always have only 2 palettes:

1. `logical_palette`

    This palette has color cycling / swapping applied but no global
    effects such as brightness / fade-in.

2. `system_palette`

   This palette is the actual palette used for rendering.

   It is usually `logical_palette` with the global brightness setting
   and fade-in/out applied.

Additionally, we now keep the k-d tree around and use it to
update single colors.

The colors that are color-cycled / swapped are never included
in the k-d tree, so the tree does not need updating on color
cycles/swaps.
2025-06-09 14:14:29 +01:00
Gleb Mazovetskiy a49b1f2d58 Extract Is{Any,None}Of out of engine.hpp
Untangles some of the dependencies
2025-01-08 09:54:56 +09:00
staphen b66b6c611b Produce multiple controller button events for SDL_JOYHATMOTION events 2022-12-05 05:05:07 +01: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 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
Gleb Mazovetskiy 9b65eca49b Remove Art and related functions 2022-08-08 14:29:45 +01: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
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
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
Anders Jenbo 72656b3011 Move path and palette to the engine folder 2022-06-24 16:34:20 +02:00
Anders Jenbo 99181fd709 Move more files to the engine folder 2022-06-24 11:08:15 +02:00
Gleb Mazovetskiy 73f9dd45ab Move embedded dialog assets to the MPQ
If we can't find `devilutionx.mpq`, we can't render a dialog either,
because the MPQ contains the fonts.
2022-06-19 18:59:06 +02:00
Gleb Mazovetskiy 9d2948c782 Loading screen: Free the background early
Frees the background after blitting it once in the loading screen.
This gives the game more RAM for the actual loading.
2022-06-15 12:22:28 +02:00
Gleb Mazovetskiy 8514cc80a9 Migrate embedded button data to PCX
It is a bit smaller that way.

Also renders the non-embedded dialogs as PCX.
The embedded dialog is still raw pixel data because it is larger as PCX.
2022-06-13 09:54:01 +01:00
Gleb Mazovetskiy 9e9b656b88 DiabloUI: Render backgrounds as PCX
The backgrounds can be quite large, for example
the Hellfire title background is a 2.4 MiB PCX file.

Previously, we converted all background to SDL surfaces.
This required extra memory, e.g. the 2.4 MiB Hellfire
title background uses 4.6 MiB as an SDL surface.

Changes the background to render directly from PCX instead
to reduce the allocator pressure.
2022-06-13 09:54:01 +01:00
obligaron d86c4e5d84 Introduce GetUIRectangle() to distinguish between UI and main panel 2022-05-29 20:20:44 +02:00
staphen 7b0ae932b0 Blit UI surface to game surface when waiting for game data 2022-05-29 20:05:41 +02:00
Anders Jenbo 1409e604f5 Reduce string conversions 2022-03-20 11:04:15 +01:00
staphen 74a77666b9 Improve behavior of ToControllerButtonEvent() 2021-12-24 23:08:41 +01:00
Anders Jenbo 4dd8b121ec Replace TTF with PCX font 2021-09-29 18:13:48 +02:00
Anders Jenbo 958087ab86 Switch TTF render to UTF-8 2021-09-24 03:03:58 +02:00
Juliano Leal Goncalves 20d356a6eb ♻️ Leverage 'Point' in art_draw functions 2021-08-30 06:45:51 +02:00
Vladimir Olteanu 56946fc5d7 progress.cpp: use TTFWrap::RenderText_Solid 2021-08-24 00:49: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
Vladimir Olteanu c57560674e Use smart pointers for UI items
vector::push_back(new Foo(...)) leaks if resizing fails
2021-07-08 03:37:47 -07:00
Gleb MazovetskiyandVictor Luchits f9d20b44d6 🎉 Hardware cursor (SDL2-only)
Disabled by default because of these known issues:

1. When clicking on inventory item, it briefly appears a bit shifted (in the wrong coordinates).

   This issue can happen with software cursor as well, but is a lot more
   obvious with the hardware cursor.

2. Cursor is scaled with nearest-neighbour scaling, which may look a bit different from
   how the rest of the graphics are scaled.

See also previous attempt: https://github.com/diasurgical/devilutionX/pull/955 by @viciious

Co-authored-by: Victor Luchits <[email protected]>
2021-06-19 01:03:40 +02:00
Anders Jenbo c66604c7ad 🐛 Do not render text as UTF8 for now 2021-04-30 21:32:27 +02:00
Anders Jenbo dbfa9c27a5 ✨ Enable translation for all menus 2021-04-25 06:55:11 +02:00
Anders Jenbo cc164985a3 🎨 Correct type checks in src sub-folder 2021-04-22 20:33:24 +02:00
Anders Jenbo 191d98207b 🎨 readability-identifier-naming on DiabloUI 2021-04-22 00:50:07 +02:00
Anders Jenbo f004c78824 🧹 performance-unnecessary-value-param 2021-04-22 00:08:19 +02:00
Anders Jenbo b978d80119 🎨 llvm-include-order 2021-04-19 20:11:20 +02:00
Anders Jenbo bb4e1960e7 🎨 modernize-use-nullptr 2021-04-19 16:02:05 +02:00
Gleb Mazovetskiy ff798a5e43 🧹 DiabloUI/progress.cpp: Move to anonymous namespace
Also removes the unused `char dialogText[256];`
2021-04-17 13:37:04 +02:00
Anders Jenbo 8c821e98d3 🚚 Restructure files 2021-04-16 03:57:22 +02:00