99 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 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 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 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
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 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 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
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 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 62d067b653 Remove utils/stdcompat/abs.hpp 2023-08-14 01:54:29 +01: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
DakkJaniels ad19caf667 Move hp/mana display and item graphics to gameplay options 2023-07-14 03:12:29 +02:00
qndel c362808165 debug path command (#6101) 2023-05-13 10:20:15 +01:00
qndel 3500dc1861 code cleanup 2023-05-11 20:03:31 +02: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
Anders Jenbo 6998906b32 Hellfire: let light affect the player 2023-04-24 17:51:39 +02:00
Anders Jenbo ec9d1b5550 Rename _oLight to applyLighting 2023-04-19 19:41:10 +02:00
Gleb Mazovetskiy 8408743eed Draw item labels before the monster health bar
Fixes #5867
2023-03-26 11:57:49 +01:00
obligaron 36ecc50fcb Always use infravision in Arenas 2023-03-13 01:00:30 +01:00
KPhoenix a1fbf5253f enum talk_id -> enum class TalkID 2023-02-09 13:04:01 +01:00
Gleb Mazovetskiy 98294e0ad5 Optimize MissileData: 32 bytes -> 24
23 bytes used, 1 spare byte in the padding.
2023-02-07 08:08:04 +01:00
Gleb Mazovetskiy 0a6a8e8aa0 Clean up missile data access
Replace enum static casts with `GetMissile(Sprite)Data`.
2023-02-03 14:37:44 +00:00
KPhoenix 7947b99511 Implement new enum class 2023-02-03 05:05:12 +01:00
Gleb Mazovetskiy 1788d2f8ec Remove miniwin
Event handling code moved to `engine/events.{hpp,cpp}`.
2023-02-01 16:06:57 +00:00
staphen dd6ce177f7 Derive viewport geometry from player position 2023-01-30 04:22:33 +01:00
Gleb Mazovetskiy 527e876fff Disable item labels when in store
Also disable ground item outlines on hover when in store.
2023-01-22 15:58:12 +01:00
c99f7cf644 Floating numbers (#5639)
Co-authored-by: qndel <[email protected]>
Co-authored-by: Stephen C. Wills <[email protected]>
2023-01-22 07:20:10 +01:00
KPhoenix 8db521727d enum missile_id -> enum class MissileID
Changes `enum missile_id` to `enum class MissileID`
2023-01-18 17:17:25 +00:00
Anders Jenbo bb2463862c Use Position in AddItemToLabelQueue() 2023-01-12 09:56:47 +01:00
Anders Jenbo a29fc3a074 Correct casing for Player::isWalking() 2023-01-12 09:42:49 +01:00
Gleb Mazovetskiy e06ca9a016 dun_render: Remove unused argument from RenderTile
Now that we pass the mask into `RenderTile`, we no longer need to pass
`levelPieceId`.
2022-12-14 10:12:24 +01:00
Gleb Mazovetskiy aa2f88e5f6 Remove software cursor state for hardware cursor
Switching between software and hardware cursor could cause a glitch
as described in #5560.

Fixes #5560
2022-12-08 12:09:36 +01:00
Gleb Mazovetskiy 79b330825d dun_render: Avoid Invalid tile type
1. Do not call `RenderTile` with invalid values to begin with.
2. Move mask selection out of `RenderTile`.
2022-12-05 01:32:29 +01:00
Gleb Mazovetskiy 44ed0296d8 dun_render: Overhaul mask handling
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.
2022-12-04 21:53:52 +01:00
Gleb Mazovetskiy 5024bc0f07 Show FPS up to 1 decimal point
If FPS < 100, print it with 1 decimal point.
Useful for measuring performance impact on low-end devices.
2022-12-03 21:42:18 +01:00
Gleb Mazovetskiy aca4aae3c1 dun_render: Remove the use of LightTableIndex
Replaces the global with an argument.
2022-11-25 15:00:04 +01:00