boyestrous / elite-vr-cockpit

A SteamVR Overlay providing a virtual throttle and joystick and holographic buttons for ship functions, with custom integration into Elite Dangerous
Other
21 stars 1 forks source link

holographic button labels #2

Closed boyestrous closed 1 year ago

boyestrous commented 1 year ago

Add a way to put text labels on top of the holographic buttons

boyestrous commented 1 year ago

Borrowing heavily from the tooltip classes, I was able to get button labels to display on top of the existing holographic buttons. I still need to figure out how to move the label to one side and maybe detect overlap/collision).

The method I used is as follows:

  1. Each button needs a Rendertexture with the text for the label. These are now created programmatically through the ControlButtonManager at the same time as each button instance is generated. This allows the (future) ability to let the user adjust the text.
  2. ControlButtonAssets now have a field called "label", which can be optionally used to specify a shorter version of the label text. Also added the abstract function GetLabelText and renamed GetTooltipText
  3. When a label is not specified, it defaults to the Tooltip text
  4. A new component ButtonLabelDisplay has been added to the ControlButton prefab, it borrows heavily from the TooltipDisplay script to create an overlay with the RenderTexture.
  5. CockpitSettingState has a new value ButtonLabelsEnabled. When it changes, a SteamVR event is triggered, which all ButtonLabelDisplay components are listening to toggle their active state.
  6. The MetaPanel now includes a Help button (question mark icon) that will activate or deactivate the button labels (by changing the CockpitSetting).

I debated using the CockpitStateController instead of CockpitSettingState, but I felt this setting fit better in SettingState because it doesn't change the functionality, it just changes a user preference. CockpitStateController seemed more focused on handling EditMode vs MenuMode, etc.

boyestrous commented 1 year ago

I figured out that I could move the button label to a child component, which made it able to be separately positioned, the labels now display nicely underneath each button.

I also renamed the TooltipTextCapture to RenderTextureTextCapture, since it's used for more than tooltips.

This is ready to go.