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

incorrect vertical size of uilist menus #75698

Closed
db48x opened this issue Aug 15, 2024 · 7 comments · Fixed by #76356
Closed

incorrect vertical size of uilist menus #75698

db48x opened this issue Aug 15, 2024 · 7 comments · Fixed by #76356
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds Info / User Interface Game - player communication, menus, etc. (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@db48x
Copy link
Contributor

db48x commented Aug 15, 2024

Describe the bug

Every line of text added above or below the menu items in a uilist menu causes the window to be a few pixels too short. This causes the end of the menu to be clipped. The more text there is, the more is clipped.

The uilist measures the text it is given to discover how large the menu should be. Is this some mismatch between how we (or our modified version of ImGui) measures text and how it renders it?

Attach save file

n/a

Steps to reproduce

Acquire multiple activatable objects (such as lamps, cigarettes, etc) and then use the sleep menu.

Expected behavior

I expect the menu to be the right size! Crazy, I know.

Screenshots

Two lines of text, slightly clipped at the bottom:

Screenshot from 2024-08-03 08-19-43

Four lines, more clipping:

Screenshot from 2024-08-03 08-24-58

Versions and configuration

  • OS: Linux
    • OS Version:
  • Game Version: 809cfa6-dirty [64-bit]
  • Graphics Version: Tiles
  • Game Language: System language []
  • Mods loaded: [
    Dark Days Ahead [dda],
    Magiclysm [magiclysm],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth]
    ]

Additional context

No response

@db48x db48x added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Aug 15, 2024
@db48x
Copy link
Contributor Author

db48x commented Aug 15, 2024

@katemonster33, do you have any thoughts on this?

@qtquazar
Copy link

qtquazar commented Aug 16, 2024

/confirmed

Can confirm this issue, and that it happens on many, many boxes. Especially noted on the bandaging menu that only the very top of the text for 'disinfection' status shows if the 'bandage' status text is also showing.

Box is clearly not wrapping to the actual size of the needed text, and just cuts off wherever. Guessing #75673 broke several things and this was only partially fixed in #75684

edit2: horizontal information like the amount of time a clothing disassembly takes is also completely missing now.

edit3: @db48x maybe i should be login separate bug reports on this... proficiencies also appear to have been broken by the #75673 change. some now display greater than 100% as the 'percent' sign is spilling over onto the next line. unsure if this is cosmetic or changing behaviour, but i'm credited with proficiencies i'm sure i never hit 100% in, but am now showing greater than 100%. also, those over 100% have not disappeared from the list. prof

@db48x
Copy link
Contributor Author

db48x commented Aug 19, 2024

The proficiency list is an interesting bug, but it isn’t drawn using ImGui. Do file that one separately.

The butchery menu is filed as #75813; thanks for reminding me about it.

@RenechCDDA
Copy link
Member

Yeah something is screwy here.

image

This actually takes up 170px, but the size allotted by additional_height in uilist::calc_data() is only 150px

@RenechCDDA
Copy link
Member

RenechCDDA commented Sep 11, 2024

Hm this is... closer? Something's strange. The area for text seems to be drawn about 1 pixel larger (in y) for every line it should have than the calculation provides for. e.g. during testing additional height was calculated as 450px, but drawn as roughly 472px in the y dimension for 21 cigars.

index 9c4768909f..eaadebd435 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -633,7 +633,8 @@ void uilist::calc_data()
     ImVec2 text_size = {};
     if( !text.empty() ) {
         text_size = calc_size( text );
-        text_size.y += s.ItemSpacing.y * 2.0;
+        float expected_num_lines = text_size.y / ImGui::GetTextLineHeightWithSpacing();
+        text_size.y += ( s.ItemSpacing.y * 2.0 * expected_num_lines );
     }
 
     ImVec2 desc_size = {};

1 cigar:
image

6 cigars:
image

21 cigars:
image

@RenechCDDA RenechCDDA added (S2 - Confirmed) Bug that's been confirmed to exist ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Sep 11, 2024
@RenechCDDA
Copy link
Member

Better patch where I don't double-count the spacing. No wonder it was screwy!

index 9c4768909f..9cc2ac9e69 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -633,7 +633,8 @@ void uilist::calc_data()
     ImVec2 text_size = {};
     if( !text.empty() ) {
         text_size = calc_size( text );
-        text_size.y += s.ItemSpacing.y * 2.0;
+        float expected_num_lines = text_size.y / ImGui::GetTextLineHeight();
+        text_size.y += ( s.ItemSpacing.y * expected_num_lines ) + ( s.ItemSpacing.y * 2.0 );
     }
 
     ImVec2 desc_size = {};

1 cigar:
image

6 cigars:
image

21 cigars:
image

41 cigars:
image

@RenechCDDA
Copy link
Member

Applying that patch to the desc_size footer also seems to resolve the butchery window issue.

before:
image

after:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds Info / User Interface Game - player communication, menus, etc. (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants