BetterHud icon indicating copy to clipboard operation
BetterHud copied to clipboard

Support total variable for positioning popups within a group

Open lulu2002 opened this issue 6 months ago • 1 comments

Hi, thank you for the amazing work on better-hud! I’m currently working on a layout that involves displaying multiple popups within the same group, and I’m trying to create a horizontally centered layout similar to a pyramid alignment, like this:

1:         0  
2:      -20  20  
3:   -40   0   40  
4: -60 -20  20  60

However, currently there’s no way to dynamically get the total number of active popups in a given group for a specific player. This makes it difficult (or impossible) to write general-purpose x-equation logic that adapts based on how many popups are being shown at that moment.

Feature Request

Would it be possible to expose a total variable within the pixel.x-equation (and maybe y-equation) context?

The variable would represent the number of currently active popups in the same group for that player. This way we can implement a clean, centered alignment regardless of how many are currently shown.

Example Use Case

timer_lock_mode:
  x: 50
  y: 0
  push: true
  unique: true
  sort: first
  group: "global_timer"
  move:
    duration: 30
    pixel:
      x-equation: (t - 1 - (total - 1) / 2) * 40
      y-equation: 5

In this example, the formula would allow every popup to be centered based on the total count and its order (t) in the group.

Would love to hear your thoughts on whether this is feasible or fits within the direction of the project. Thanks again for your time and great work!

lulu2002 avatar Jul 06 '25 11:07 lulu2002

I actually tried to implement this myself, but haven’t been successful so far 😅

Still not very familiar with the BetterHud source code, so if you have any suggestions or feedback, I’d really appreciate it!

This is a feature I really want, and I’d be more than happy to contribute — currently, this PR is mostly generated with Cursor AI just to sketch out the idea quickly. I was hoping to iterate from there, but haven’t even been able to get the functionality working yet.

Right now, the main issue seems to be with getComponent(), which results in rendering [] (empty string) during runtime.

EXP PR link for reference: https://github.com/lulu2002/BetterHud/pull/1/files

Thanks again, and open to any guidance you might have!

lulu2002 avatar Jul 06 '25 11:07 lulu2002