498 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 bd3d17975c Fix MSVC SDL1 warnings 2023-12-22 17:03:01 +01:00
obligaron 95205294e8 Fix MSVC x86 warnings 2023-12-22 17:03:01 +01:00
staphen 4f8dc6c4d0 Remove byte order logic from half-transparency lookups 2023-12-20 00:05:49 +01:00
obligaron dc4cd43e8f Remove duplicate function definitions from control.h 2023-12-14 22:17:57 +01:00
obligaron 244d3d2f3a Remove scroll wheel hack 2023-12-14 22:17:57 +01:00
Gleb Mazovetskiy 876055b272 Migrate effect.cpp data to TSV 2023-11-14 02:27:46 +00: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
obligaron 2b15eb8d03 Fix MSVC warnings from headers 2023-11-07 00:27:42 +01: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 c5a5dc9f5c Fix a few MSVC warnings 2023-11-05 12:57:59 +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
staphen 7b8dad456e Add asserts to Displacement::magnitude() 2023-11-01 23:15:18 -04:00
Gleb Mazovetskiy 5d9d5c6872 Lua: require supports loads from assets
Implements a `require` function that supports built-in modules like so:

```lua
local log = require('devilutionx.log')
```

It falls back to reading from assets, so this loads `lua/user.lua`:

```lua
local user = require('lua.user')
```

The bytecode for the asset scripts is cached, in case we want to later
support multiple isolated environments.

There may be a simpler or better way to do this.

It's good enough for now until someone more knowledgeable
about Lua comes along.
2023-11-02 02:24:06 +00:00
Gleb Mazovetskiy 026907e4b9 Displacement#distance: Use a naive hypot impl
`std::hypot` is much slower than a naive implementation.
It has the advantage of extra precision but we don't need that at all.
2023-11-02 00:45:26 +00:00
Gleb Mazovetskiy 17d5f05ada Fix some compilation warnings 2023-11-02 00:42:44 +00:00
Gleb Mazovetskiy 63da74300b Console: Scrolling and history navigation
Scrolling: PageUp/Down and mouse wheel.

History navigation:

* Up/Down navigates the input history.
* Shift+Up/Down navigates the output history (allowing us to copy/paste the
outputs, I imagine this will be very handy).
* Duplicates are skipped.
2023-11-01 20:05:02 +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
Gleb Mazovetskiy 9e2608bd98 Fix DiabloMsg rendering for CJK
Fixes #6675
2023-10-14 00:14:42 +02: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
ephphatha c1f3dcb705 Use safer versions of random number functions instead of GenerateRnd 2023-09-19 16:52:40 +02: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 16a6fc62e1 Deduplicate some of the MPQ handling
Reuse libmpq functions where possible instead of our own.
2023-09-10 02:16:15 +01:00
Gleb Mazovetskiy 0f77cc3797 Force-inline methods to improve debug build perf
This has little or no effect on the optimized build
but significantly improves performance of the headless debug build

`timedemo_test` on my machine goes from 3s to 2s.
2023-09-10 02:14:01 +01:00
Gleb Mazovetskiy 70ff515f48 Stream demo messages
This entirely eliminates the demo memory overhead.
2023-09-02 20:54:24 +01:00
Gleb Mazovetskiy 65e0ad88d2 Further reduce demo file size
The vast majority of events are rendering events:

 Type        | Count
-------------|------:
 Rendering   | 58,971
 MouseMotion | 19,651
 GameTick    |  6,414
 MouseButton |    516
 Key         |      7
 Custom      |      1

Encodes Rendering events in a single byte when possible.

Demo file size: 253,410 bytes -> 194,439 bytes
2023-09-02 16:43:59 +01:00
Gleb Mazovetskiy d31a7b5c2c Log Demo settings 2023-09-01 21:59:20 +01:00
Gleb Mazovetskiy af869ac732 Merge branch 'master' into dev-merged 2023-09-01 20:49:34 +01:00