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

Add the option to open the ImGui demo from the main menu for debugging #72171

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

ZeroInternalReflection
Copy link
Contributor

Summary

None

Purpose of change

The new ImGui windows are a bit tricky to debug and modify because, until contributors (me, I'm talking about me) are familiar with the system, we need to go through a bit of a mental checklist:

  • Is this a bug in my code?
  • Is this a bug in cata_imgui?
  • Is this a bug in ImGui?
  • Is this how ImGui is supposed to display things?
  • Am I using the wrong ImGui feature for this UI element?
  • Can I even do that in ImGui?

Describe the solution

One way to answer several of these questions is with quick access to the ImGui demo screen:
Option_on_main_menu

ImGui_Demo_Tiles

  • If it works in the demo screen, then the bug is probably on our end.
  • We get to see a bunch of different ImGui elements, and can refer to src/third-party/imgui/imgui_demo.cpp to see a specific example of how they're implemented.
  • There's an example of a minimum-viable cataimgui::window implementation that puts things on the screen

Describe alternatives you've considered

  • Putting the demo screen under the debug menu
    Then you need to load into the game to see it. The main menu is much faster
  • Hiding it behind another option so that only people working on the UI see it
    Possible, perhaps even beneficial, but I haven't done it yet.

Testing

Does the demo screen work perfectly? No, no it does not.

  • I needed to tweak the drawing code to give us a way to force things to the back, because otherwise it would be hidden behind a blank ui_adaptor window
  • Font loading for CJK characters is definitely broken (see Imgui y/n query popup fails to display translated string on Windows #72162), as the example display widget doesn't work
    Current_font_loading_CJK
  • Curses is a bit twitchy, where the demo screen doesn't show up until after you resize the window
    • Also, the curses demo screen is gigantic and way off to the bottom right, suggesting that our window positioning/resizing isn't working
      ImGui_Demo_Curses
    • There seems to be an odd quirk where the window won't detect a mouse click unless you wiggle the mouse slightly

But this is valuable information for debugging our own windows

Additional context

@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. [C++] Changes (can be) made in C++. Previously named `Code` astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Mar 4, 2024
@katemonster33
Copy link
Contributor

Nice idea! Second thought, since you brought up debugging - add a second option to open the Metrics window (ImGui::ShowMetricsWindow()) this window has lots of helpful state data about ImGui and is very nice when debugging.

@ZeroInternalReflection
Copy link
Contributor Author

Nice idea! Second thought, since you brought up debugging - add a second option to open the Metrics window (ImGui::ShowMetricsWindow()) this window has lots of helpful state data about ImGui and is very nice when debugging.

I believe that one's accessible from the demo screen under "Tools" (currently on a different branch so I can't check for sure)

Similarly, I saved myself a bunch of grief once I realized having the "Inputs & Focus" widget open would show whatever input ImGui was seeing.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 4, 2024
@Maleclypse Maleclypse merged commit 0673c53 into CleverRaven:master Mar 5, 2024
22 of 28 checks passed
SurFlurer added a commit to SurFlurer/Cataclysm-DDA that referenced this pull request Mar 19, 2024
…ion/ImGuiDemo"

This reverts commit 0673c53, reversing
changes made to 03d25c2.
SurFlurer added a commit to SurFlurer/Cataclysm-DDA that referenced this pull request Mar 19, 2024
…ion/ImGuiDemo"

This reverts commit 0673c53, reversing
changes made to 03d25c2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants