Commit Graph
138 Commits
Author SHA1 Message Date
Stephen C. Wills 5e778431c3 Deterministic timer simulation for shrine messages in demo mode (#6516) 2023-08-29 13:46:49 +02:00
Gleb Mazovetskiy 8c1a847f41 Remove utils/stdcompat/string_view.hpp 2023-08-14 09:59:14 +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 c858ab4d2c Fix some compilation warnings
also removes a couple of unused filesystem includes
2023-03-12 13:21:40 +00:00
staphen 27dfaeb9dc Use herosounds for class-specific quest speech IDs 2023-03-08 22:38:01 +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
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
Anders Jenbo ac2bf9aaac Limit what gets called in headless mode 2022-07-13 18:54:36 +02:00
Gleb Mazovetskiy d152d2c0fb Add OptionalOwnedCelSprite 2022-07-03 12:26:39 +01:00
Anders Jenbo 0cc5ee4344 Clean up variable definitions 2022-06-30 02:59:23 +02:00
Anders Jenbo 99181fd709 Move more files to the engine folder 2022-06-24 11:08:15 +02:00
Gleb Mazovetskiy 8e9c9e0238 Reduced the size of OwnedCelSprite* by 8 bytes
`OwnedCelSpriteWithFrameHeight`: 40 -> 32
2022-06-20 01:11:22 +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
Anders Jenbo 1409e604f5 Reduce string conversions 2022-03-20 11:04:15 +01:00
Anders Jenbo 718c46e7fe Remove use of tempstr 2022-03-19 06:03:19 +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
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
Gleb Mazovetskiy bc9031ad54 WordWrapString: Fix state after starting a new line
After starting a new line, we restart the processing from the line break
position, so we need to set `nextCodepoint` correctly.

Fixes #3449
2021-11-10 01:48:55 +00:00
Anders Jenbo bff9140995 Expand buffers to handle Bulgarian translation 2021-10-26 17:57:46 +02:00
Anders Jenbo 203766f51b Fix OOB write with long dialog translations 2021-10-23 19:55:42 +02:00
Gleb Mazovetskiy 0c694edaba WordWrapString: Wrap on punctuation
Useful for Chinese and Japanese, which do not have spaces between words,
nor whitespace after punctuation.
2021-09-30 18:16:31 +02:00
Anders Jenbo 7f6dec6dca Fix extra content rendered in dialogs
More then just the given line was being plased in the line buffer which
caused a lot of double rendering and sometimes also invalid UTF-8
resulting is stray question marks under the text
2021-09-25 09:05:51 +02:00
Anders Jenbo 7771a08d03 Translatable mainpanel 2021-09-19 07:21:52 +02:00
Siddharth singh chouhan bcb332b7b0 Move documentation from implementations to declarations 2021-09-14 09:55:55 +02:00
Anders Jenbo 7169882b1f ✨ Implement new font rendering 2021-09-12 01:37:28 +02:00
Juliano Leal Goncalves 9f4438fa22 🚚 Rename 'TextDataStruct' struct to 'Speech' (#2805) 2021-09-06 17:47:07 +02:00
Anders Jenbo 8df8b940c4 Handle some clang-tidy issues 2021-08-07 16:30:14 +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 9b8bf92575 Rename quest 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 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
Gleb Mazovetskiy cb0dae8590 🚚 Rename CelOutputBuf to Surface and extract 2021-07-03 05:33:32 -07:00
Gleb Mazovetskiy e40b1963f9 🚚 engine.h: Extract CelSprite and file loading 2021-06-21 01:36:20 -07:00
Anders Jenbo 0d5d8cb1d4 💚 Fix NOSOUND 2021-05-30 19:42:36 +02:00
Kalebe Alves 118efe8e6d Use Point/SDL_Rect for control functions coordinate system 2021-05-28 19:57:16 +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 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
Anders Jenbo 4b577329f4 ♻️Refactor towner initialization 2021-05-07 00:30:23 +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
Gleb Mazovetskiy 57172e48ed 🔨 ⚙️ CMake: Add NOSOUND option
This option completely disables all audio handling, including audio
loading code and dependencies.

Dialog text length is estimated to be somewhere between
Cain and Griswold speed.
2021-04-29 19:43:45 +02:00
Anders Jenbo 48dbb47d70 🌐 Apply static translations 2021-04-29 01:21:28 +02:00
thebigMuh ad8f342db0 Adding constness 2021-04-26 23:30:02 +02:00
Anders Jenbo 7912e510f0 🎨 Clean up overuse of SDL types 2021-04-24 17:07:07 +02:00