Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextWrapPos on ExtuiTooltip instead of ExtuiText doesn't wrap the text. #472

Open
FineRedMist opened this issue Oct 30, 2024 · 4 comments
Open

Comments

@FineRedMist
Copy link
Contributor

I have attempted solutions to common problems

Yes

I have checked that my game version is supported

Yes

OS

Windows 10

Platform

Steam

Description

If I do (in lua):

local tooltip = win:Tooltip()
tooltip.ItemWidth = 400
tooltip.TextWrapPos = 400
text = tooltip:AddText()

The text won't wrap.

However:
local tooltip = win:Tooltip()
text = tooltip:AddText)
text.ItemWidth =400
text.TextWrapPos = 400

The text does wrap.

Indications

This is my code trying to generate tooltips based on SE code.

Diagnostic Files

No response

Steps to Reproduce

local tooltip = win:Tooltip()
tooltip.ItemWidth = 400
tooltip.TextWrapPos = 400
text = tooltip:AddText("Twas brillig and the slithy toves did gyre and gimble in the wabe. All mimsy were the borogroves, and the momeraths outgrabe. Beware the jabberwock my son, the jaws that bite, the claws that catch, beware the jub jub bird, and shun the frumious bandersnatch.")

Expected Behavior

The above code should work with the text wrapped.

Actual Behavior

The text is not wrapped in the tooltip.

@FineRedMist
Copy link
Contributor Author

Oh my, I just realized this could be an issue with ImGui, not SE. If that is the case, I'm not sure I can achieve my objective. I may try splitting the sentence to see if that works.

@FineRedMist
Copy link
Contributor Author

I was hoping to be able to highlight the different kinds of damage, similar to how the original BG3 tooltips do:

image

@Norbyte
Copy link
Owner

Norbyte commented Nov 30, 2024

Thinking on it, this is probably an order of operations issue.

TextWrapPos does this in the pre-render phase:

void ImGui::PushTextWrapPos(float wrap_pos_x)
{
    ImGuiWindow* window = GetCurrentWindow();
    window->DC.TextWrapPosStack.push_back(window->DC.TextWrapPos);
    window->DC.TextWrapPos = wrap_pos_x;
}

However, tooltips are considered to be a separate window with their own DC, so the TextWrapPos call is made before we start rendering the tooltip window and the value is essentially ignored.

@FineRedMist
Copy link
Contributor Author

Thank you for the update. I worked around it by having separate lines for the information and doing color there (instead of inline). It would be cool to be able to embed codes into the text to change color in the same string of text.

Selectors_Spells .

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

No branches or pull requests

2 participants