283 Commits
Author SHA1 Message Date
Gleb Mazovetskiy 647f8c38e4 Slightly improve CJK infobox rendering
It still isn't perfect (there just isn't enough space) but we now
cut off fewer pixels at the bottom.
2024-01-11 09:34:35 +00:00
obligaron dc4cd43e8f Remove duplicate function definitions from control.h 2023-12-14 22:17:57 +01:00
ephphatha 3b458376bb Use a pointer to a player instance instead of network id for cursor hovering 2023-11-09 17:40:50 +01:00
obligaron 95940a4c7e Fix MSVC warnings in engine\render\* 2023-11-08 17:03:19 +01:00
Gleb Mazovetskiy 5fc6ce608f Lua: Overhaul events
1. `Events` global is replaced with `require('devilutionx.events')`.
2. Table is simplified and documented.
3. `On` removed from the event names as it was a bit redundant.
4. Functions are camelCase for consistency (e.g. `add` instead of
   `Add`).

Example script:

```lua
local events = require("devilutionx.events")
local render = require("devilutionx.render")
local message = require("devilutionx.message")

local function greet()
  message("Hello from " .. _VERSION)
  print("Hello from ", _VERSION)
end
events.GameStart.add(greet)

local function drawGreet()
  render.string("Hello from " .. _VERSION, 10, 40)
end
events.GameDrawComplete.add(drawGreet)
```
2023-11-07 02:44:10 +00:00
Gleb Mazovetskiy e02dc1f9dd Console input: Word-wrap-related cursor fixes
1. Handle word breaks in the prompt, e.g. `"> " -> "\n"`.
2. Handle word breaks in the original newline for all whitespace, not just `"\n"`.
2023-11-06 21:42:58 +00:00
Gleb Mazovetskiy b30b712cbb Lua: Add basic autocomplete in the console 2023-11-03 19:19:45 +00:00
Gleb Mazovetskiy dbfa204944 Lua: Set warn function
Previously, warnings went nowhere.
2023-11-02 15:16:31 +01:00
Gleb Mazovetskiy 17d5f05ada Fix some compilation warnings 2023-11-02 00:42:44 +00:00
Gleb Mazovetskiy 3ea4996367 Add a basic Quake-style console
Enabled only in Debug mode.

Runs Lua similar to the `lua` CLI.
Supports multiline input with Shift+Enter.

Missing features:
1. Scrollback.
2. Input history on up/down.

Open with backtick, close with Esc.
2023-10-31 23:19:56 +00:00
Gleb Mazovetskiy 55b0fc5c26 Text inputs: Selection, copy, cut
Adds shift selection, Ctrl+C, and Ctrl+X handling.

Also fixes left-right movement for non-ASCII characters.
2023-10-30 20:34:12 +00:00
Gleb Mazovetskiy de6eac137b Split up lua bindings a bit
```lua
local render = devilutionx.render

local function drawGreet ()
  render.string("Hello from " .. _VERSION, 10, 40)
end
Events.OnGameDrawComplete.Add(drawGreet)
```
2023-10-26 03:48:56 +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 09ab58343c Migrate gold drop/withdrawal to text_input
With this, all text input is handled in a unified way.
2023-10-24 20:11:04 +01:00
Gleb Mazovetskiy fdb5738815 Add cursor support to DiabloUI and chat
Supports move left/right/home/end, backspace, delete, and Ctrl+V.
2023-10-24 01:56:54 +01:00
Gleb Mazovetskiy 5b62bf7eec Lua improvements
1. A conformant `print`.
2. `drawString`.
3. `OnGameDrawComplete` event for drawing things on screen.
2023-10-15 19:47:12 +01:00
staphen 61e51f2349 Additional cleanup for WordWrapString() 2023-10-15 12:42:39 +02:00
staphen 99bf0e4e3c Insert newline for words longer than width in WordWrapString() 2023-10-15 12:42:39 +02:00
Gleb Mazovetskiy 88bbf4f913 Improve DiabloMsg handling
1. Simplified implementation.
2. Now adjusts the box size to fit the content (e.g. when wrapping
   failed or when there are too many lines).
2023-10-14 09:45:24 +01:00
Gleb Mazovetskiy d1d27c8368 Rename error -> diablo_msg 2023-10-14 09:45:24 +01:00
Eric Robinson ffc7190898 Automap: Add minimap display option (#6612) 2023-09-26 03:37:35 +02:00
Eric Robinson 4c7e2edd06 Automap: Transparency (#6607) 2023-09-24 21:30:44 +00:00
Gleb Mazovetskiy fa155d4ffd Dungeon tiles: Port over some cleanups from #6636 2023-09-23 18:02:43 +01:00
Gleb Mazovetskiy 3477d2f33f Revert "dun_render: Add DunTileColorMap for baked light"
This reverts commit 827eb9705d.
2023-09-23 18:02:43 +01:00
Gleb Mazovetskiy 14e32bd8f3 DrawDungeon: Remove dRendered check
This check was only needed when the tile to the east was drawn first.
Checks for this with a single bool rather than a whole bitset.
2023-09-20 04:47:42 +01:00
Gleb Mazovetskiy 827eb9705d dun_render: Add DunTileColorMap for baked light
Refs #6631
2023-09-19 18:04:36 +01:00
Gleb Mazovetskiy 4c87f335ac DrawDungeon: Move checks out of DrawObject/Item
Avoids calling `FindObjectAtPosition` and similar pre-checks twice.
2023-09-19 00:07:53 +01:00
Gleb Mazovetskiy e5c426c315 Make IsWall easier for the compiler to inline
This appears to be a very hot function.
Makes it fully inlineable (even in Debug mode).
2023-09-18 21:26:13 +01:00
Eric Robinson d63fa514ab Automap: Pentagram (#6606) 2023-09-16 01:12:03 +02:00
Gleb Mazovetskiy b83637add8 Use a C array for transparency LUT for debug perf
In a debug build, `std::array` accesses are function calls.

Timedemo on my machine:
* Before: 45.39 seconds	141.3 FPS
* After:  40.20 seconds	159.5 FPS
2023-09-10 17:57:15 +01:00
Gleb Mazovetskiy b64ee0e190 Use if constexpr in clx/dun_render 2023-09-10 10:22:19 +01:00
Gleb Mazovetskiy af869ac732 Merge branch 'master' into dev-merged 2023-09-01 20:49:34 +01:00
Gleb Mazovetskiy 62e9aa0448 MissilePosition: Use WorldTilePosition
Reduces struct size and makes the types of coordinates more obvious.
2023-08-29 20:00:54 +01:00
Gleb Mazovetskiy 5355146d51 Use structured bindings 2023-08-29 12:56:49 +01:00
Stephen C. Wills 45dbe6aa61 Shift software cursor graphic and remove special casing (#6512) 2023-08-26 16:45:36 +02:00
Gleb Mazovetskiy ba4def9382 Use utils/algorithm/container.hpp in more places 2023-08-19 19:57:11 +09:00
Gleb Mazovetskiy cbf51cd5ab DrawStringFormatArg: Use std::variant 2023-08-18 02:14:01 +09:00
Gleb Mazovetskiy 26f42520fa Fix unused variable warnings 2023-08-16 06:02:17 +09:00
Gleb Mazovetskiy 8c1a847f41 Remove utils/stdcompat/string_view.hpp 2023-08-14 09:59: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 62d067b653 Remove utils/stdcompat/abs.hpp 2023-08-14 01:54:29 +01:00
obligaron f59e3aaffb Introduce IsPointWithinClx 2023-08-12 17:47:31 +02:00
obligaron d5642daeb4 Introduce GetScreenPosition 2023-08-12 17:47:31 +02:00
obligaron 578ce01432 Introduce Towner/Player/Object/Item/Monster::currentSprite/getRenderingOffset 2023-08-12 17:47:31 +02:00
Gleb Mazovetskiy 7a5e5f73e6 Support language-specific font variants
Refs #3538
2023-08-12 17:44:30 +02:00
Gleb Mazovetskiy 8101e2c0ba Add c_any_of and friends
Adds handy helpers for performing algorithms on the entire container.
They're prefixed with `c_` for container.

This naming convention is identical to some popular C++ libraries, such
as Abseil.
2023-08-12 16:24:01 +01:00
Gleb Mazovetskiy d6b7949dab Fonts: Use pre-cropped CLX sprites
Built-in font size decreased by 121,587 bytes
(2,287,332 -> 2,165,745).

Fixes #6361
2023-07-16 06:02:19 +02:00
DakkJaniels ad19caf667 Move hp/mana display and item graphics to gameplay options 2023-07-14 03:12:29 +02:00
Gleb Mazovetskiy d8cd147ac7 Re-encode CL2 on load
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
2023-07-13 01:44:16 +01:00