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

ImGui windows don't render when screen is small (too short) #72470

Closed
Brambor opened this issue Mar 17, 2024 · 7 comments · Fixed by #72501
Closed

ImGui windows don't render when screen is small (too short) #72470

Brambor opened this issue Mar 17, 2024 · 7 comments · Fixed by #72501
Labels
Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (S2 - Confirmed) Bug that's been confirmed to exist

Comments

@Brambor
Copy link
Contributor

Brambor commented Mar 17, 2024

Describe the bug

When you (click / press key) to open a window in the main menu, it looks like nothing happened, just as if the input broke, since you cannot see the selection moving and sound pinging. When you resize the game window, the ImGui window shows up.

The keybinding and popup windows both fail to render.

Attach save file

N/A

Steps to reproduce

  1. Launch game
  2. Set screen width height to very small (actually 1000px is around the braking point)
  3. Open keybindings menu
  4. Nothing shows
  5. Resize game window
  6. ImGui window shows, (but needs resizing to update every time)

Expected behavior

Windows always render even with the smallest size CDDA supports.

Screenshots

image

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19045.4170 (22H2)
  • Game Version: 0.G-8021-g0bb40773a9-dirty [64-bit] - actually, it is clean master 0bb4077
  • Graphics Version: Tiles
  • Game Language: English [en]
  • 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

I don't know what is the version doing. I am recompiling on master, stashing everything, editing files to bump their edit date and editing them back so that VS recompiles it.
Rebuilding the whole project.
Still the "version" is garbage.

This report should be better, but I am gonna go to sleep now.

@Brambor Brambor added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Mar 17, 2024
@Brambor Brambor changed the title ImGui windows don't render when screen is small (too narrow) ImGui windows don't render when screen is small (too ~narrow~ short) Mar 17, 2024
@Brambor Brambor changed the title ImGui windows don't render when screen is small (too ~narrow~ short) ImGui windows don't render when screen is small (too ~~narrow~~ short) Mar 17, 2024
@Brambor Brambor changed the title ImGui windows don't render when screen is small (too ~~narrow~~ short) ImGui windows don't render when screen is small (too short) Mar 17, 2024
@Brambor
Copy link
Contributor Author

Brambor commented Mar 17, 2024

This seems to be the limiting height (still works)
image

This doesn't work anymore (cannot scroll etc.):
image

@NetSysFire NetSysFire added the ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds label Mar 17, 2024
@NetSysFire
Copy link
Member

CC @katemonster33

@ZeroInternalReflection
Copy link
Contributor

ZeroInternalReflection commented Mar 18, 2024

I did a bit of testing on this one. A couple of observations:

  • This is specifically a Tiles issue. Curses seems to work fine all the way down to 80x24.
  • On my setup, the window will show up even at small sizes, but it will be broken at the same size of ~1000px (Edit: It looks like the exact height where it breaks is going from TERMY 61->60 at 975 pixels)
  • Even when broken, input is still clearly being registered. I can click the 'x' in the top right and the screen goes away. Similarly, if you click on buttons/the scrollbar/use text controls, the screen will not display updates, but will implement whatever you input (observe how things change when resizing the window forces a display update):
simplescreenrecorder-2024-03-17_22.25.53.mp4

(I also checked that the behaviour was the same prior to #72353)

@ZeroInternalReflection
Copy link
Contributor

A bit more testing, unfortunately still inconclusive. This feels like an issue where the ui_adaptor is made too big for the window and fails to draw (see, e.g. #52688), but I don't really have any evidence to back that up, and can't find where it might be going wrong.

To back up my previous assertion that this is Tiles only, here's an example of the keybindings screen showing up in Curses at 80x24:
https://github.com/CleverRaven/Cataclysm-DDA/assets/89038572/d605b796-72d3-4192-98fb-aacf6b75db78

To see if the window is being sized correctly I added a bunch of size checks to demo_ui::draw_controls() . You can see that at a height of 976 pixels, the screen works. At 975 pixels, it breaks. However, SDL, ImGui, and the numbers being given to the underlying ui_adaptor all seem to make sense for a screen height of 975 pixels.
https://github.com/CleverRaven/Cataclysm-DDA/assets/89038572/35740121-6bf6-4c1a-88d4-092223772614

One note is that on Curses, demo_ui only shows the ImGui demo screen. This screen that I populated with information for testing does not show up in Curses. Is that relevant? Maybe? Have I figured out why? No.
I had a notion that the Tiles build was somehow making a ui_adaptor that the Curses version didn't and that's what was breaking, but every configuration I tried had the same number of ui_adaptors in the Keybinding screen and the ImGui demo screen.

@NetSysFire NetSysFire added (S2 - Confirmed) Bug that's been confirmed to exist Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! and removed (S1 - Need confirmation) Report waiting on confirmation of reproducibility labels Mar 18, 2024
@Brambor
Copy link
Contributor Author

Brambor commented Mar 18, 2024

I just noticed that in-game keybindings don't work either, nor a new screen I made (when the height is too small).

I wrongly assumed they did work.

@katemonster33
Copy link
Contributor

best i can tell, something is going wrong internal to imgui. below a certain window size, imgui simply stops rendering. input gets handled silently, but it's like the SDL backend just kicks the bucket. resizing the window forces a single draw operation to happen, otherwise you get nothing.

@katemonster33
Copy link
Contributor

Spent a few more minutes looking at it, this actually is a CDDA problem, sorry. Because the actual ImGui drawing code was moved into ui_manager::redraw_invalidated, when redraw calls happen too far from calls to refresh_display, then the ImGui window is not actually updated on the screen - this seems to happen when the window is small. We need to either fix the way rendering is done on SDL, or add a hack to force refresh_display to be called every time ui_manager::redraw_invalidated is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Not particularly urgent or easy (see Good First Issue for this), but help is appreciated with this! ImGui Anything related to the new ImGui UI for SDL/tiles or ImTui for curses builds (S2 - Confirmed) Bug that's been confirmed to exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants