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 Sidebars to the Flight UI #5431

Merged
merged 12 commits into from
Dec 2, 2022

Conversation

Web-eWorks
Copy link
Member

This PR is quite overdue to be opened, but I'm finally getting enough time to try to land it.

Finally implementing a concept from @nozmajner many years ago, I've added two sidebars to the "world view" and interfaced the existing UI elements (gauges, system overview window, comms log) with them for a consistent display paradigm. I've added a new cargo hold display widget to the sidebars, and the sidebar architecture is designed to make adding additional widgets very easy.

NOTE: this PR is an open call to design/implement additional useful data display in the new sidebars - I'd like a few more sections of useful information before we ship this update.

These sidebars also represent a bit of experimentation with theming and smooth animations for the UI, hopefully the first of many such improvements to come.

Here's a bit of a lengthy gameplay video showing how everything works (and also showing off a bug with the deliver cargo missions... I did not in fact jettison any cargo, but I apparently had to pay $2,660 anyways.)

2022-11-29.02-17-06.mp4

This PR also includes a few other improvements to the codebase, the most notable of which I've listed here:

  • I've significantly expanded the type information and completion data available to a Lua language server, and added support to our scan_enums.py script to auto-generate information about the various Constants tables.
  • I've also made general improvements to the pigui ui code in some spots, though for details you'll have to reference the commit messages as I've honestly forgotten a lot of what I've done in this PR in the ~five months since I started working on it.
  • @impaktor will rejoice, as I've exposed the most important parts of the ImGui Tables API to lua - now you can data-science to your heart's content! 😄 Operator's manual not (yet) included.

Some CoreObject classes are extended with Lua methods - this allows the Lua extension file to be processed first when running static analysis on e.g. `local Game = require 'Game'`.
- ui.addCursorPos / addCursorScreenPos to replace the ui.setCursorPos(ui.getCursorPos() + Vector2(...)) paradigm
- ui.getLineHeight() to retrieve the height of the current line.
- ui.addWindowPadding() to fiddle with window internal state and allow mixing full-width window content with padded window content.

Added Engine.time and Engine.frameTime variables (tracking real wall-clock time) for use in UI animations.
Sidebars are responsible for managing the display of "HUD" widgets like gauges and the collapsed comms log.

They also manage the display of active modules which can be toggled on or off by a button bar in the top left and right corners of the screen.

Pertinent information (e.g. Comms Log, system overview, flight information, cargo / cabin state) will be displayed here, and mission modules can register additional displays for their content.
Port these game view modules to display using the new sidebar paradigm.

Add a RectCut implementation for handling display layout in sidebar areas.
Modules incrementally subtract needed space from the available layout area to ease future addition of modules.
Query the window content size from last frame and use it to determine how tall to make the window.

Widgets should use exclusive mode if they want to use implicitly sized child windows for scrolling.
Added minimum useful set of table functionality to LuaPiGui - further exposure should be done as needed.
- ui.inlineIconButton draws an icon button sized to match a regular button.
- ui.calcButtonSize returns the size of a button drawn with the specified label.
- ui.getButtonHeight returns the height of a button (similar to ui.getTextLineHeight).
- ui.textAligned renders a string of text with fluid alignment between left center and right justification.
Display ship cargo and provide option to jettison multiple commodities at once.
@impaktor
Copy link
Member

Cool.

  1. Maybe there shold be the same "click" sound effect when clicking those buttons? Or some new sound? @WKFO
  2. I'll get back to you on more gauges. I just have to do some code archeology, as indicated on IRC.

@WKFO
Copy link
Contributor

WKFO commented Nov 29, 2022

I don't really think those UI interactions need a click-clacking sound, especially with the smooth animation in place. Maybe something subtle.

@bszlrd
Copy link
Contributor

bszlrd commented Nov 29, 2022

I agree about it being subtle

@Web-eWorks
Copy link
Member Author

If anyone is interested, Pioneer seriously needs a larger library of UI interaction sound effects - button clicks and mouseover sounds, confirm / deny sound cues, subtle menu open/close sounds, etc. It's much better to have them available in-tree for UI coders to pick from and use as needed then it is to make said UI coders hunt for appropriately-licensed suitably thematic assets (as usually they just don't use sounds at all, or worse use the existing "OK" sound we have for everything).

That rant's not really relevant to this PR though; I'm merging this given the generally positive feedback received so far!

@Web-eWorks Web-eWorks merged commit 0467477 into pioneerspacesim:master Dec 2, 2022
@Web-eWorks Web-eWorks deleted the flight-ui-hotbars branch December 2, 2022 03:18
@impaktor
Copy link
Member

impaktor commented Dec 3, 2022

@Web-eWorks If interested, I have a branch (now rebased to master), where I'm pondering how to set parameters for a gauge:
https:/impaktor/pioneer/tree/scout-mission

The gauge has hard coded criteria for when it's to progress towards 100%, and I'd like player to input that into some kind of input field, or that's my current thinking. Perhaps you'd like to have a look at the code.

If I remember correctly, it works like so: player takes mission to scan surface of planet, when entering frame, scanner will progress towards 100% if player is below/at altitude +/- some tolerance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants