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

Faction camp creation uilist doesn't wrap, overflows screen #77142

Closed
sparr opened this issue Oct 19, 2024 · 1 comment · Fixed by #77326
Closed

Faction camp creation uilist doesn't wrap, overflows screen #77142

sparr opened this issue Oct 19, 2024 · 1 comment · Fixed by #77326
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility

Comments

@sparr
Copy link
Member

sparr commented Oct 19, 2024

Describe the bug

The uilist for choosing a type of faction camp doesn't wrap its text, causing the interface to be wider than my screen for the barebones camp.

Attach save file

N/A

Steps to reproduce

  1. talk to NPC
  2. ask them to build a camp

Expected behavior

text wraps

Screenshots

image

Versions and configuration

  • OS: Linux
    • OS Version: LSB Version: n/a; Distributor ID: EndeavourOS; Description: EndeavourOS Linux; Release: rolling; Codename: rolling;
  • Game Version: 4466eb1-dirty [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

Additional context

uilist_impl::draw_controls is calling cataimgui::draw_colored_text with no wrap_width

I tried this:

                        float column_text_width = ImGui::GetContentRegionAvail().x;
                        cataimgui::draw_colored_text( str1, color, column_text_width );

but the width produced was ~7e31 which is... too big.

I tried this:

                        const size_t window_width = str_width_to_pixels( TERMX );
                        const float table_column_width = window_width / 2.0f;
                        cataimgui::draw_colored_text( str1, color, table_column_width );

and it generated an appropriate width of 960, then I could see the text in folded_msg split into three lines, which is also good.

However, cataimgui::draw_colored_text doesn't actually wrap text! It does this:

    std::vector<std::string> folded_msg = foldstring( text, chars_per_line );

    for( const std::string &line : folded_msg ) {

but doesn't output newlines between the "lines", producing the same output as with no wrapping.

I tried this:

    int l = 0;
    for( const std::string &line : folded_msg ) {
        if( l++ != 0 ) {
            ImGui::NewLine();
        }

and this gets it to display just the first line, with the other lines cut off below. Adding newlines in other places for testing causes other uilists to misbehave, demonstrating that the uilist doesn't resize vertically for multi-line items. Adding a newline to every item results in the bottom half of items being lost.

Also, even when drawing only the first line, the uilist interface is still the full wider-than-my-screen width, so something is wrong there too.

That's as far as I got before I had other issues to attend to. I may try to pick this up again later, but it may be better handled by someone more familiar with ImGui.

@sparr sparr added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Oct 19, 2024
@mqrause
Copy link
Contributor

mqrause commented Oct 19, 2024

I believe that's (part of) what #76513 is trying to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants