Skip to content

Lua Hooks extension and D2-Style Tooltip mod.#8470

Open
Rasti-i wants to merge 6 commits intodiasurgical:masterfrom
Rasti-i:tooltips-lua
Open

Lua Hooks extension and D2-Style Tooltip mod.#8470
Rasti-i wants to merge 6 commits intodiasurgical:masterfrom
Rasti-i:tooltips-lua

Conversation

@Rasti-i
Copy link
Copy Markdown

@Rasti-i Rasti-i commented Feb 15, 2026

Introduces a new infobox Lua module, wire infobox-related Lua events and rendering hooks, and add a new default Tooltips Lua mod with Color/Text formatting, item comparison and hint behavior.

  • New infobox event API in events.lua InfoBoxPrepare, AfterFloatingInfoBoxDraw, BeforeUniqueInfoBoxDraw.
  • New gamepad API, allowing lua to read controller state, parse inputs and register new padmappings.
  • Engine/UI now calls those hooks during info box rendering in control_infobox.cpp and before unique-item panel draw in scrollrt.cpp
  • Lua runtime gained item-aware event overloads and handler introspection in lua_global.hpp and lua_global.cpp, enabling conditional hook paths.
  • Lua player module gained equipped-item accessors.
  • Lua render module gained utility drawing/measurement helpers for half-transparent rect and text.
  • New built-in Tooltips Lua mod with:
    per-line and in-line text coloring/dividers,
    formatting changes following D2/D2R style,
    toggling of unique info box rendering and printing of unique powers to the tooltip if floating infobox setting is enabled,
    dynamic action hints(currently only in English),
    Shift comparison for an additional floating panel with equipped items. (if floating infobox turned on)

Closes #8431

Floating infoboxes enabled:
2026-02-1518-18-04-ezgif com-video-to-gif-converter

Floating infoboxes disabled:
2026-02-1518-19-27-ezgif com-video-to-gif-converter

Gamepad support:
2026-02-16-062616_hyprshot

Introduce a dedicated infobox Lua module, wire infobox-related Lua events and rendering hooks, and add the Tooltips Lua mod with item comparison and hint behavior. Keep items module aligned with master and move unique info-box visibility hooks under devilutionx.infobox for module cohesion.
Comment thread Source/options.cpp Outdated
if (ShowUniqueItemInfoBox) {
DrawUniqueInfo(out);
LuaEvent("BeforeUniqueInfoBoxDraw");
if (ShowUniqueItemInfoBox)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be truthy right?

__doc_OnPlayerGainExperience = "Called when Player gains experience.",

---Called before an info box is rendered. Passes hovered item (or nil) and whether it is floating.
InfoBoxPrepare = CreateEvent(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need those 3 events? Do you think we can have an event that triggers when user hovers the item and your module listens to the event and triggers the render logic?

"Returns the screen width", []() { return gnScreenWidth; });
LuaSetDocFn(table, "screen_height", "()",
"Returns the screen height", []() { return gnScreenHeight; });
LuaSetDocFn(table, "drawHalfTransparentRect", "(x: integer, y: integer, width: integer, height: integer, passes: integer = 1)",
Copy link
Copy Markdown
Collaborator

@yuripourre yuripourre Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file could be a separate PR. With groundwork for the infobox PR.

size_t lineIndex = 0;
for (const std::string_view &line : lines) {
if (lineColors.hasDividerBeforeLine(lineIndex) && lineIndex > 0) {
DrawHalfTransparentHorizontalLine(out, { linePos.x, linePos.y - (lineHeight / 2) }, rect.size.width, PAL16_GRAY + 10);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am little confused, if you rendering the infobox using a cpp file, why do you need the lua methods (or vice-versa)?

🤔

Comment thread Source/options.cpp
prev = it;
}

auto inserted = actions.emplace_after(prev, key, name, description, defaultInput, std::move(actionPressed), std::move(actionReleased), std::move(enable), index);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it worth a comment here, why it is necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Item description text can be individually color highlighted to signify actionable information

2 participants