-
Notifications
You must be signed in to change notification settings - Fork 341
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
Integrate Dear ImGui and implement a new settings menu with it + more #576
Conversation
still a bit hacky, but shows imgui windows that can be clicked etc
the integration of that at least, the menu is still a stub
idStr::(V)Format() is a static (v)printf-like function that returns and idStr. Can be used like a better va(), or for idStr mystr = idStr::Format( "number of items: %d", myarr.Num() );
I actually did this before the prototyping of a keybindings menu in the imgui example code, so the prototype is actually based on this. I'll merge the code from the prototype back once it's done.
The original binding menu uses #str_07183 between keys - this should be " or ", but in the windows demo that entry is missing in strings/english.lang
they're part of the regular list now. this will help with the actual binding implementation I'll merge next
I first developed that as a prototype in https://github.com/DanielGibson/dhewm3/blob/imgui/neo/libs/imgui/examples/example_sdl2_opengl2/main.cpp there one can also find a commit history from writing that code, even though not all commit messages are overly helpful :-p
Also fix MSVC build: For some reason Microsoft's sad excuse of a compiler only sets __cplusplus to a value from this millenium if the /Zc:__cplusplus compiler option is set, but that's only supported from VS2017 15.7 on. The alternative is to use _MSVC_LANG, which always holds the version that __cplusplus *should* have...
You can pry X macros from my cold dead hands
it's nicely self-contained, I'll release it as a mini-library/addon for Dear ImGui on https://github.com/DanielGibson/Snippets/
- write code uses fewer/shorter string literals - code generated by WriteImGuiStyleToCode() has nicer alignment - small improvements in some comments
Pause the game (with g_stopTime) when the settings menu is opened while ingame, unpause it when it's closed. If the menu is open while ingame and an ImGui window has focus, the mouse cursor is shown. If the player clicks outside an ImGui window, it gets unfocused and the cursor is hidden and the player can look around. Pressing F10 (or whatever key is bound to "dhewm3Settings") will give focus back to an open ImGui window, pressing it again then will close the settings window, pressing it once again afterwards will open the settings window again. handleMouseGrab() (in sys/events.cpp) now checks if sys_imgui thinks that a cursor should be shown (via D3::ImGuiHooks::ShouldShowCursor()) and if so, shows it and ungrabs the mouse. This, together with D3::ImGuiHooks::NewFrame() checking ShouldShowCursor() to (unset) ImGuiConfigFlags_NoMouseCursorChange, should prevent flickering cursor problems that sometimes occurred when ImGui's SDL2 backend and dhewm3 disagreed on whether the cursor should be visible.
* Binding menu makes sure that the AllBindingsMenu always gets focus when opened * Give binding-related popups slightly rounder edges * Move Game Options tab behind Video and Audio Options * Make warning overlays a bit less translucent
In the main menu the ImGui/SDL/System cursor was only drawn when it was over an ImGui window, so only the Doom3 cursor is shown when outside of ImGui windows. The only problem with this is that the Doom3 cursor is only shown in the parst of the window actually covered by the main menu, not the black bars that are drawn on the left/right for widescreen-resolutions when scaling the menu to 4:3 is enabled (which it is by default). So now the ImGui cursor is also drawn when the cursor is on those black bars (if any). Also tweaked the windowtitle background colors a bit.
Not supported with SDL1.2 - but that's only still supported by dhewm3 because I'm too lazy to rip it out :-p
Upstream commit: "Disabled: nested tooltips or other non-child window within a BeginDisabled() block disable the disabled state. (dhewm#211, #7640)" Should be in the next Dear ImGui release
the stb libs, miniz and minizip are now always optimized to speed up performance, esp. level loading times, in debug builds. So far the stb libs implementation were dragged into the source file that uses them, now I created additional source files just for them so those can be optimized while the engine source files using those libs can remain unoptimized in debug builds.
ImGuiDir now is a proper enum, not just a typedef of int that happens to have a similar name to the actual enum
I can crash dhewm on WIn10 with this procedure when switching between 'real fullscreen' and window mode (or vice versa)
I can switch successfuly when the imgui is already open/visible. the new options dialogs are great! |
Seems like calling ImGui::CalcTextSize() is only safe after (or at the end of) NewFrame()
Thanks for testing and reporting that bug - I just pushed a commit that should fix it :) Glad you like the new menu! |
I see these compile errors on MSYS2 and tried mingw32 on Linux.
|
is this really all that's needed?!
incl. setting in SettingsMenu With SDL 2.0.5 and newer this change is applied immediately, 2.0.0 to 2.0.4 need a vid_restart (with SDL1.2 we don't support it at all)
6f5f5ec
to
ac8eec9
Compare
Here is an updated build for Windows: dhewm3-1.5.4pre-imgui4_win32.zip Since the last one there are a few fixes and one new feature: @j4reporting: Those mingw issues should be fixed, can you test the lastest code? |
Mingw builds successfuly with latest updates. |
"vid_restart partial" only changes the window size or its fullscreen (or windowed) state, without recreating everything. If that fails (or antialiasing settings have changed), it will fall back to a full vid_restart (this behavior is different than original "vid_restart partial" that probably was implemented in Vanilla Doom3 but not dhewm3) This is used for Alt-Enter (which toggles between fullscreen and windowed state) and when pressing the Apply button in the new Video Menu
vid_restart partial always switches back to windowed mode ignoring r_fullscreeen=1 setting |
Toggling with Alt-Enter relies on idRenderSystem::IsFullScreen() which returns glConfig.isFullscreen That can only work if GLimp_SetScreenParms() actually sets glConfig.isFullscreen Thanks j4reporting for reporting this! :)
Damn, how did I not notice this.. Thanks for reporting (and testing!), it should be fixed now :) |
was thinking the same ;)
nope. unchanged only vid_restart works. in windowed mode:
r_customwidth / height is 1920x1080 |
try again, turns out I only tested with r_fullscreenDesktop 1 🙈 |
confirmed. do you plan to make this the default for vid_restart and only attempt the complete vid_restart if the partial attempt failed? |
My plan was to keep it like this.
|
it's queried from SDL so it should be up-to-date. Using it in GLimp_SetScreenParms(), as it mostly did the same SDL calls to get the current state for the partial vid_restart
…ions Now the CVars are set immediately and "Apply" only does `vid_restart partial`, while "Reset" resets the CVars to the values that were set when opening the menu. This also works the other way around: Changing a CVar (in the console or other menu or r_fullscreen with Alt-Enter) is immediately reflected in the menu. Furthermore, "fullscreen desktop" now is its own setting (=> can be set even if windowed mode is selected), to accommodate switchting between windowed and fullscreen with Alt-Enter
I reworked the resolution/windowed/MSAA section of the Video Options. Now the CVars are set immediately and "Apply" only does I think this is more consistent with how the rest of the menu works. I also made "fullscreen desktop" a separate option, so one can configure windowed mode but still configure fullscreen desktop to specify what happens on Alt-Enter. |
This integrates the Dear ImGui GUI toolkit and using that provides a new settings menu (which can be opened with
F10
unless that key is bound already, or by enteringdhewm3Settings
in the console).Dear ImGui support can be disabled when building dhewm3, and is automatically disabled for SDL1.2, as it requires SDL2.
The settings menu has many options that Doom3s options menu doesn't have, like:
vid_restart
)While I implemented this I also added some features to dhewm3:
m_invertLook
in_allowAlwaysRunInSP
r_swapInterval
or in the menu, of course; needs SDL2)s_alHRTF
s_alOutputLimiter
: Configure OpenAL's output-limiter which temporarily reduces the overall volume when too many too loud sounds play at once, to avoid issues like clippings_scaleDownAndClamp
: Clamp and reduce volume of all sounds to prevent clipping or temporary downscaling by OpenAL's output limiterAs these are a lot of changes, this could need some testing!
Here's a current build for Windows: dhewm3-1.5.4pre-imgui3_win32.zip