Backports the text rendering code from 1.6 to 1.5.
Done by starting with the current master's engine/render/text_render
and backporting things as-needed until it worked.
CLX rendering and text input handling are also backported as part of
this change.
This version of NDK finally comes with updated libc++.
The last update to libc++ in NDK was in early 2020.
This update brings lots of improvements and bugfixes from upstream
libc++.
NDK 26 only support SDK 21+, so we bump `minSdkVersion` as well.
Original Blizzard encoder is slightly less optimal than our encoder.
While size in RAM in less of a concern for the non-`UNPACKED_MPQS`
build, smaller files are faster to render.
Savings for unpacked and minified MPQs:
* diabdat.mpq: 918,311 bytes.
* hellfire.mpq: 313,882 bytes.
Example player graphics (note that only a few are loaded at any given time for single player):
* diabdat/plrgfx/warrior/: 366,564 bytes.
Example monster graphics savings:
* diabdat/monsters/skelbow: 5,391 bytes.
Based on the implementation from https://github.com/diasurgical/devilutionx-graphics-tools/pull/6
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
1. Use `fmt::format_int` directly instead of parsing a format string.
2. Use `AppendStrView`.
3. Define the varargs versions using fold expressions when available.
4. Add tests.
Removes most `FMT_COMPILE` calls.
`FMT_COMPILE` results in better performance but larger code size.
Removes `FMT_COMPILE` calls for places that are called infrequently,
i.e. not on every frame.
RG-99 binary size reduced by ~4 KiB.
With this, we no longer require `std::filesystem` support to create the
save file directory when it does not exist.
Note that by default the save file directory exists because it is
created by SDL, so this is mostly useful on platforms that override the
save directory or use `UNPACKED_SAVES`.
Each resampler allocates an input buffer and an output buffer.
Since we create ~100 audio stream objects (1 per `sfx_MISC` effect),
the memory cost of these buffers adds up.
Avoids creating a resampler when the audio sampler rate matches the
output sample rate. This is mostly the case when the output sample
rate is 22050.
If a config directory did not exist, the ini file was
not saved at all.
Only implemented for targets that support `std::filesystem` or `std::experimental::filesystem`.
These are all the targets except nxdk and iOS (only supported on iOS 13+).
The locale code used the `forceLocale = "en"` fallback when
the locale was set to English, so switching from English
did not actually change the language.
This allows forcing the locale without changing the settings.
The `forceLocale` option also lets us avoid changing the locale in settings if fonts.mpq is missing, fixing the following scenario:
1. System locale is ja
2. Launch the game -- fonts are missing
3. Close the game, download fonts.mpq
4. Launch the game again -- it is now in English because the settings have changed
We notice that masks can be described by 2 parameters:
1. Whether they have 0 or 1 as their high bits.
2. Whether they shift to the left or to the right on the next line.
Describing masks this way allows us to lift them to template variables and simplify the code.
We also avoid handling the mask in the `RenderLine` loop entirely.
Also fixes a foliage rendering bug: Transparent foliage pixels were previously blended but they should have been simply skipped.
1. Fixes the return value (bytes rendered).
2. Fixes line wrapping / end-of-rendering based on the given rectangle:
1. Accounts for `BaseLineOffset`.
2. Fixes an off-by-one error for the y coordinate.
3. Wraps the cursor when needed.
3. Fix chat input box dimensions (height is 3 * line height).
4. Set the hint that indicates that we do not render the current
IME suggestion (SDL_TEXTEDITING). This indicates to IME
that it should render the suggestion instead.
1. Unifies SDL1 and SDL2 text input handling.
2. Moves game-specific text input handling out of misc_msg.
3. Disables Unicode processing when not inputting text in SDL1.
This fixes gold withdrawal in SDL1.
When using `UNPACKED_MPQS`, avoid all the SDL machinery for reading
files.
This is beneficial not only due to reduced indirection but also because
we can test for the file's existence and get the file size without
opening it, which is much faster.
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