Gleb Mazovetskiy
d71a54dba8
Render main panel buttons as CLX
...
Converted with:
```
pcx2clx --num-sprites 3 data/talkbutton.pcx && rm data/talkbutton.pcx
```
Sizes:
```
Surface(63, 114) -> CLX 7296 -> 5336 -26.9%
Surface(53, 48) -> CLX 2688 -> 2324 -13.5%
```
2022-08-04 15:16:00 +02:00
Gleb Mazovetskiy
8f7dd16ac3
Show an error on outdated devilutionx/font.mpq
2022-08-03 16:37:04 +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
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
d152d2c0fb
Add OptionalOwnedCelSprite
2022-07-03 12:26:39 +01:00
Gleb Mazovetskiy
3178dd5158
Replace most uses of sprintf with fmt ( #4837 )
2022-07-01 17:02:56 +02:00
Anders Jenbo
72656b3011
Move path and palette to the engine folder
2022-06-24 16:34:20 +02:00
Gleb Mazovetskiy
8e9c9e0238
Reduced the size of OwnedCelSprite* by 8 bytes
...
`OwnedCelSpriteWithFrameHeight`: 40 -> 32
2022-06-20 01:11:22 +02:00
Gleb Mazovetskiy
02d448267a
Render fonts as PCX (-420 KiB RAM)
...
Reduces peak memory consuption in game by ~420 KiB.
This is because the PCX renderer applies the palette on the fly while
rendering, meaning we do not need to duplicate the font for different
palettes.
This approach is also a bit slower than precomposed palettes (still
plenty fast).
2022-06-15 16:59:59 +02:00
Gleb Mazovetskiy
1fc8ecb6f6
Add fmt::runtime annotations for C++20 support
...
`fmt` requires non-contexpr format string arguments to be wrapped in
`fmt::runtime` in C++20.
2022-06-14 12:46:36 +01:00
qndel
f84c35d2dc
fix typos
2022-06-01 17:12:22 +02:00
Gleb Mazovetskiy
961e1b584b
Always load fonts as CEL
...
There appear to be no drawbacks, only advantages.
2022-04-25 05:31:26 +01:00
Gleb Mazovetskiy
978bae1a15
Add a helper for loading PCX as CEL from path
2022-04-25 05:31:26 +01:00
Gleb Mazovetskiy
2b161e5535
An option to convert fonts to CEL in-memory
...
Reduced RAM usage by 200 KiB with no performance drop, perhaps even an
improvement.
2022-04-25 05:31:26 +01: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
ade8aba822
Fix some more warnings
2022-04-14 01:26:29 +02:00
ephphatha
93068de918
Address type conversion warnings in WordWrapString
2022-04-03 14:56:01 +02: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
1519e995cf
Move store graphics out of stores.cpp
...
These graphics are used in various places outside of `stores.cpp`.
2022-01-30 14:56:04 +01:00
KPhoenix and Anders Jenbo
a08026097a
Chat Interface Revision ( #3840 )
...
Co-authored-by: Anders Jenbo <[email protected] >
2021-12-25 10:11:42 +00:00
Gleb Mazovetskiy
1de202cfe0
DrawString: Fix IsCJK definition
...
Fix IsCJK to include Hiragana, Katakana, Bopomofo, etc.
2021-11-27 15:11:52 +01:00
Gleb Mazovetskiy
48ddb2ea06
DrawString: Fix line height for tall codepoints
2021-11-27 15:11:52 +01:00
Gleb Mazovetskiy
bffe7dd071
DrawStringWithColors: Fix {} support
2021-11-25 12:22:27 +01:00
Gleb Mazovetskiy
af168fd8df
Add DrawStringWithColors
...
A way to color parts of the string differently while keeping the color
information out of the string itself.
This is an alternative to #3546 .
2021-11-25 00:26:16 +00:00
Anders Jenbo
9ea6d9c9d1
Tweak Hangul font width
2021-11-19 03:40:00 +01:00
Anders Jenbo
a6f17fe072
Adjust width of CJK and Hangul fonts
2021-11-18 02:26:11 +01:00
Anders Jenbo
5e97bfa1e8
Adjust to new CJK font width
2021-11-16 04:10:07 +01:00
Gleb Mazovetskiy
f45270e9ab
RenderString: Fix width calculation after \n
...
Fixes #3456
2021-11-10 01:48:55 +00: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
Gleb Mazovetskiy
e3dc241c2f
Correctly handle ZWSP in WordWrapString
2021-11-10 01:48:55 +00:00
Gleb Mazovetskiy
40b1dc7a12
WordWrap: Require whitespace to break after Latin punctuation
...
This fixes cases such as `github.com`.
As we now require a space after Latin punctuation, we can remove
the list of Latin punctuation symbols and break on the space itself.
We still disallow linebreaks between consecutive fullwidth punctuation
symbols.
2021-11-08 00:11:04 +01:00
Gleb Mazovetskiy
e1dc7df3a5
Fix crash in WordWrapString
...
Fixes #3433
2021-11-07 23:21:21 +01:00
Gleb Mazovetskiy
8e5bc0597a
Don't line-break in the middle of a punct sequence
...
Also removes a redundant copy of the input string.
Fixes #3420
2021-11-07 19:03:35 +00:00
Gleb Mazovetskiy
e9a9daa794
DrawString: Stop allocating
...
Switch to a state-machine UTF-8 decoder from the branchless one.
This allows us to avoid copying the string on every `DrawString` call.
2021-11-07 04:17:50 +01:00
Gleb Mazovetskiy
3d308983a8
Migrate to libmpq
...
libmpq is a much simpler alternative to StormLib for reading MPQ archives.
We use our own fork of libmpq: https://github.com/diasurgical/libmpq
Impact:
* DevilutionX is now a lot more portable. Unlike StormLib, libmpq only
needs platform-specific code for Windows.
* Locks around file access **removed** (instead we duplicate the file descriptor for streamed audio only).
* RAM usage is **300 KiB** lower than StormLib.
* Stripped release linux_x86_64 binary is **32 KiB** smaller.
* Amiga build now hangs instead of crashing.
2021-11-06 23:51:42 +00:00
Gleb Mazovetskiy
117695489b
DrawArt: Fix bounds check ( #3395 )
...
The bounds checks were performed against the global screen dimensions
instead of the output buffer dimensions.
Also includes some minor cleanup of DrawArt.
Fixes #3388
2021-11-05 14:17:56 +00:00
Anders Jenbo
9cee65da6c
Correct calculation for KerningFitSpacing
2021-10-24 16:28:28 +02:00
Anders Jenbo
b227afc4c4
Do not render text past first encoding error
...
Continuing past the error allows for CTD attacks using special crafted
invalid UTF-8 with a multiby indicator at the end the string
2021-10-24 16:28:28 +02:00
Anders Jenbo
11e37e972a
Port essential parts to use SDL abstraction for file access
2021-10-20 21:52:59 +02:00
Gleb Mazovetskiy
dec45920eb
Text rendering: Support Zero-width space
...
Zero-width space is a non-printing character that indicates a word
boundary.
https://en.wikipedia.org/wiki/Zero-width_space
2021-10-20 02:33:25 +02:00
Anders Jenbo
5b3abbd315
Correct dialog font full width
2021-10-17 08:40:45 +02:00
Anders Jenbo
b3546e3254
Load full width kerning programmatically
2021-10-16 02:00:30 +02:00
Anders Jenbo
f022a341b0
Avoid crashing from missing fonts
2021-10-12 21:05:19 +02:00
Gleb Mazovetskiy
f4404e1452
WordWrapString: Also break on , U+FF0C (FULLWIDTH COMMA)
2021-10-01 10:29:03 +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
4dd8b121ec
Replace TTF with PCX font
2021-09-29 18:13:48 +02:00
Anders Jenbo
d0f70d5468
Correct loading of unicode fonts past row 09
2021-09-25 03:59:00 +02:00
Anders Jenbo
704a04ae4d
Add support for Unicode fonts
2021-09-24 03:03:58 +02:00