218 Commits
Author SHA1 Message Date
Anders Jenbo bb2e189327 Convert _sfx_id in to class enum 2023-11-02 14:34:24 +01:00
Gleb Mazovetskiy e5881688f4 text_render: Replace optional args with struct
4 options args are a bit unwieldy, especially when you want
to pass only the first and the last one.

With a struct, there is no need to specify the default values
for the args in between.
2023-10-25 09:19:14 +01:00
Gleb Mazovetskiy c19bfe87fa Remove utils/stdcompat/algorithm.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 14540164a7 Remove utils/stdcompat/optional.hpp 2023-08-14 01:54:29 +01:00
Gleb Mazovetskiy 4fa3732526 Add missing <cstdint> includes
Done with the following script:

```ruby
Dir["Source/**/*.{h,c,cc,cpp,hpp}"].each do |path|
  v = File.read(path)
  next if !v.include?("uint32_t") || v.include?("cstdint")

  lines = v.lines
  line_num = if lines[2].start_with?(" *")
    lines.index { |l| l.start_with?(" */") } + 3
  else
    3
  end

  lines.insert(line_num, "#include <cstdint>\n")

  File.write(path, lines.join(""))
end
```

then fixed-up manually
2023-05-10 13:50:12 +01:00
Gleb Mazovetskiy 1788d2f8ec Remove miniwin
Event handling code moved to `engine/events.{hpp,cpp}`.
2023-02-01 16:06:57 +00:00
staphen e67e4934cc Add padmapper for gamepad customization 2022-10-17 01:01:21 +02: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 890295b6d3 In-game menu: Fix slider click handling
Previously, clicking on the slider close to the end
or near the start did nothing -- you'd have to actually
drag it to set the value to min or max.

Also cleans up the in-game menu code overall.
2022-10-03 05:42:15 +01:00
Gleb Mazovetskiy 6327e713e0 Lowercase all file paths
We want to be able to use unpacked MPQs on low-end platforms
(PS2/rg99/etc).

This is tricky on case-sensitive filesystems. Avoids case issues by
lowercasing all paths in the code (then we'll just need lowercased
listfiles).
2022-08-20 23:49:23 +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 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 a4ac41cece Replace DVL_VK virtual key codes with SDLK 2022-07-17 10:00:06 +01:00
Anders Jenbo ac2bf9aaac Limit what gets called in headless mode 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 d152d2c0fb Add OptionalOwnedCelSprite 2022-07-03 12:26:39 +01:00
Gleb Mazovetskiy 8e9c9e0238 Reduced the size of OwnedCelSprite* by 8 bytes
`OwnedCelSpriteWithFrameHeight`: 40 -> 32
2022-06-20 01:11:22 +02:00
Anders Jenbo 1203514383 Clean up use of currlevel 2022-06-07 21:35:01 +02:00
obligaron d86c4e5d84 Introduce GetUIRectangle() to distinguish between UI and main panel 2022-05-29 20:20:44 +02:00
Gleb Mazovetskiy a66ca44695 Zero-based frame indexing
Index frames starting at 0 instead of 1.
2022-04-14 04:39:26 +01:00
Gleb Mazovetskiy 7fede6c4cb Clean up owned/unowned CelSprite ambiguity
Makes `CelSprite` unowned and adds a new `OwnedCelSprite` class for
owned sprites.

This clarifies ownership and makes the code cleaner in a number of
places.

Additionally, because the `CelSprite` class is now tiny (1 less
pointer), we can pass it by-value instead of by-reference, removing a
pointer indirection in the rendering functions.
2022-03-06 04:49:13 +01:00
staphen df830f6495 Save settings before leaving the settings menu 2022-01-23 05:25:48 +01:00
Gleb Mazovetskiy c57644970f Move UiFlags and UiPanels into their own files
The first breaks circular dependency between `DiabloUI` and `text_render`.
The latter one moves `UiPanels` to a more appropriate place.
2021-11-25 12:22:27 +01:00
obligaron 677303cba9 Reduce use of view globals in game menu 2021-11-20 21:57:32 +01:00
Anders Jenbo 7771a08d03 Translatable mainpanel 2021-09-19 07:21:52 +02:00
Anders Jenbo 7169882b1f ✨ Implement new font rendering 2021-09-12 01:37:28 +02:00
BC Ko e4e368948b documentation cleanup: gmenu 2021-08-30 13:51:42 +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 a19e7b2a3b Remove some more use of miniwin 2021-07-17 23:54:13 +02:00
Anders Jenbo 35ccc8eb1c Apply clang-tidy to code 2021-07-10 17:30:15 -07:00
Anders Jenbo 74b57558c9 🚚 Move local code to anonymous namespace 2021-07-10 17:30:15 -07:00
Anders Jenbo 9ebdb6db69 General clean up 2021-07-08 03:30:25 -07:00
Anders Jenbo dce78dde62 Rename lighting globals 2021-07-08 02:01:14 -07:00
Anders Jenbo bc59218d0d More clang-tidy/Android Studio cleanups 2021-07-04 19:34:37 +02:00
Gleb Mazovetskiy cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
Juliano Leal Goncalves fd9f2099d0 ♻️ Leverage 'Point' to represent mouse position 2021-06-27 16:37:59 +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 e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
Kalebe Alves 118efe8e6d Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +02:00
qndel 4d4eadf233 fix pause font and centering (#2063) 2021-05-25 23:29:44 +02:00
Anders Jenbo 6ce8f13751 Apply clang-tidy to more code and do some related cleanups 2021-05-24 05:27:06 +02:00
Anders Jenbo 6acb49bea4 Render quest and menu text using common text rendering 2021-05-21 04:23:49 +02:00
Anders Jenbo fd96bb9ab5 Render chat messages using common text rendering 2021-05-19 14:09:33 +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
Gleb Mazovetskiy 0edfa3de66 🚚 Move CEL rendering to engine/render/cel_render.cpp 2021-05-07 00:16:40 +02:00
Gleb Mazovetskiy 1b8b62a8c2 ♻️ Store CEL width with the sprite itself
Instead of passing the CEL sprite width when drawing, store the CEL
width at load time in the new `CelSprite` struct.

Implemented for most sprites except towners, missiles, or monsters.
2021-05-01 20:51:55 +02:00
Mathieu Maret 8d8711a966 Apply static menu translations (#1728) 2021-04-27 14:20:31 +02:00
thebigMuh ad8f342db0 Adding constness 2021-04-26 23:30:02 +02:00