ImGui

Discuss the future of Warzone 2100 with us.
Post Reply
i-NoD
Code contributor
Code contributor
Posts: 318
Joined: 30 Nov 2008, 00:42
Location: In the middle of nowhere

ImGui

Post by i-NoD »

Hey everyone!

Here is a preview of something I was playing around on for some time: a UI reimplementation using popular ImGui library. This awesome project allows one to convert UI as you go, without doing a full switch, so it's relatively easy to compare old and new versions and debug any issues.

Here is a new frontend/ main menu:
Image

Here is an in-game UI, both old and new reticule, object screen and powerbar at the same time:
Image

ImGui also supports styling:
Image
User avatar
Prot
Trained
Trained
Posts: 242
Joined: 29 Nov 2010, 12:41

Re: ImGui

Post by Prot »

Very interesting. Patches available?
User avatar
andrvaut
Trained
Trained
Posts: 200
Joined: 02 Jan 2016, 12:44

Re: ImGui

Post by andrvaut »

Prot wrote: 13 Mar 2019, 12:42 Very interesting. Patches available?
https://github.com/inodlite/warzone2100/tree/imgui
vaut ΣΑ [GN], ru streamer.
Tournaments channel: https://www.youtube.com/channel/UCzusNa-54ydodtSz2TdHFww
pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 339
Joined: 13 Aug 2017, 17:44

Re: ImGui

Post by pastdue »

This is very interesting. If you have a chance, please rebase on top of the latest master. The latest master incorporates a lot of work wrapping OpenGL calls to support a future Vulkan backend. (Also options like Display Scaling & live window resizing / layout-recalculation which may impact this work. And it compiles much more easily on many platforms, to help with testing. And fixes numerous bugs. :))

I'd be happy to help work on this effort, but we really need it rebased on top of the latest master. (For one thing - 3.2.3 doesn't compile on macOS at all, and has various severe bugs on other platforms.)
User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 938
Joined: 26 Sep 2016, 19:56

Re: ImGui

Post by Berserk Cyborg »

Nice! 8)

+1 for rebasing off master before going further. There have been a lot of changes to the codebase since 3.2.3 so hopefully you don't run into too many merge conflicts, if any.
i-NoD
Code contributor
Code contributor
Posts: 318
Joined: 30 Nov 2008, 00:42
Location: In the middle of nowhere

Re: ImGui

Post by i-NoD »

I have not looked at master at all, but I would expect frontend part to apply more or less cleanly due to completely un-invasive code, it should even work with vulkan, provided that you use proper imgui backend. Please feel free to give it a try, branch was mentioned above.

Model rendering, on other hand, might require some tweaking, judging from what you described in rendering improvements...

Anyways, with model rendering it's relatively easy to churn out fancier stuff like a research view:
Image

It can benefit from color-coding stuff that is available vs already researched, but otherwise it's only a short step away from a goal-guided research!
pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 339
Joined: 13 Aug 2017, 17:44

Re: ImGui

Post by pastdue »

i-NoD wrote: 15 Mar 2019, 10:34 I have not looked at master at all, but I would expect frontend part to apply more or less cleanly due to completely un-invasive code, it should even work with vulkan, provided that you use proper imgui backend. Please feel free to give it a try, branch was mentioned above.
At the moment, you are probably the best person to try to rebase on top of master. (Also please keep in mind that we've been trying to remove Qt dependencies.) Once that's done, there are several folks who would likely be happy to help with work on this branch (including myself).
User avatar
moltengear
Trained
Trained
Posts: 170
Joined: 22 Jul 2017, 15:05

Re: ImGui

Post by moltengear »

Unfortunately ImGui is only suitable for testing, debugging something, but not for creating a product for a regular user. While it may be possible to somehow accommodate.
There are good controls in the Godot engine, Blender3d. Maybe nuclear GUI.
pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 339
Joined: 13 Aug 2017, 17:44

Re: ImGui

Post by pastdue »

moltengear wrote: 15 Mar 2019, 23:49 Unfortunately ImGui is only suitable for testing, debugging something, but not for creating a product for a regular user. While it may be possible to somehow accommodate.
There are good controls in the Godot engine, Blender3d. Maybe nuclear GUI.
Reference? There are a number of released apps / games that use ImGui for their UI.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: ImGui

Post by Cyp »

Looks interesting. One issue — as far as I can tell, ImGui has the same major problem that Warzone 2100 currently has — if clicking twice between frames, then at least one click is ignored, and the mouse position at the time of clicking is ignored. This often results in having to click about 5-10 times in a row to research or build something before it succeeds, especially during battles with many units.

There really really needs to be a separate event-handling pass (per event), as well as a rendering pass. There's an unfinished attempt (doesn't compile) here: https://github.com/Cyp/warzone2100/comm ... c3ad533800
i-NoD
Code contributor
Code contributor
Posts: 318
Joined: 30 Nov 2008, 00:42
Location: In the middle of nowhere

Re: ImGui

Post by i-NoD »

Cyp wrote: 16 Mar 2019, 09:19 as far as I can tell, ImGui has the same major problem that Warzone 2100 currently has
That's likely correct.

ImGui is plugged directly (it bypasses whatever buffers WZ has) into same SDL polling system that WZ has, plus ImGui has no queue of its own AFAICT. Here is the method that accepts events from SDL: https://github.com/ocornut/imgui/blob/8 ... dl.cpp#L83 . It will result in a "merge" of all events at the start of a frame; plus ImGui will get current/last mouse pos at each frame, as seen in ImGui_ImplSDL2_UpdateMousePosAndButtons.

You can definitely run per-event UI updates, trouble is in ImGui's "immediate" part: you'll be constructing drawing lists on every pass and then simply discarding them to avoid overpainting same frame... Although, you probably could do some optimizations like say, if you've got multiple events, mark all but last pass as a no-drawing ones and then for every window (ImGui::Begin), check if mouse is hovering on top of it and go straight to End if not, bypassing anything inside the window and keeping it to bare minimum of calculations. You could also devise a system for keypresses, e.g. reticule caring about F1-F6 and ignoring the rest.
User avatar
moltengear
Trained
Trained
Posts: 170
Joined: 22 Jul 2017, 15:05

Re: ImGui

Post by moltengear »

pastdue wrote: 16 Mar 2019, 02:23
moltengear wrote: 15 Mar 2019, 23:49 Unfortunately ImGui is only suitable for testing, debugging something, but not for creating a product for a regular user. While it may be possible to somehow accommodate.
There are good controls in the Godot engine, Blender3d. Maybe nuclear GUI.
Reference? There are a number of released apps / games that use ImGui for their UI.
Nuklear GUI has flags that allow you to customize the behavior of the window.
You can remove the curb, the ability to move controls, etc.
Nuklear GUI has more flexibility. It is possible to use both for debugging and for creating the final product.

Flags of nuklear
NK_WINDOW_BORDER - Draws a border around the window to visually separate window from the background
NK_WINDOW_MOVABLE - The movable flag indicates that a window can be moved by user input or by dragging the window header
NK_WINDOW_SCALABLE - The scalable flag indicates that a window can be scaled by user input by dragging a scaler icon at the button of the window
NK_WINDOW_CLOSABLE - Adds a closable icon into the header
NK_WINDOW_MINIMIZABLE - Adds a minimize icon into the header
NK_WINDOW_TITLE - Forces a header at the top at the window showing the title
NK_WINDOW_BACKGROUND - Always keep window in the background
NK_WINDOW_SCALE_LEFT - Puts window scaler in the left-bottom corner instead right-bottom

I don't know whether ImGui has such capabilities. I searched, I didn't find.
https://www.gamedev.net/forums/topic/69 ... ear-imgui/
It was interesting to me to read what they say about it.
Post Reply