Skip to content

Refactor GuiRotationDial, AimLock rendering#2781

Draft
oznogon wants to merge 8 commits intodaid:masterfrom
oznogon:refactor-guirotationdial-aimlock
Draft

Refactor GuiRotationDial, AimLock rendering#2781
oznogon wants to merge 8 commits intodaid:masterfrom
oznogon:refactor-guirotationdial-aimlock

Conversation

@oznogon
Copy link
Contributor

@oznogon oznogon commented Mar 12, 2026

GuiRotationDial uses sprites for the handle and ring. This limits how GuiRotationDial can be used, since resizing it also changes the width of the ring and size of the handle, and the handle's arc is fixed to 20 degrees, which happens to be the size of the default handle sprite.

Instead of using sprites, draw a circle outline and use triangle strips for the handle, and apply theme colors for direct customization.

Correspondingly refactor AimLock (the only use of GuiRotationDial) to remove its redundant rendering logic, move its radar rotation offset handling to GuiRotationDial, and fix the headers of the screens that use AimLock and AimLockButton to correctly declare their classes. The default ring thickness, which is now configurable, is also reduced to 1/10 of the radius instead of about 1/8 to avoid hiding heading tigs.

Before (right) and after:

Screenshot 2026-03-11 182906

- Workaround ambiguous resources.h includes in
  EmptyEpsilon/init/ by including SP's resources.h
- Include vectorUtils.h in components/beamweapon.cpp to ensure
  that M_PI is available
- Use _WIN32 instead of WIN32 in preprocessor ifdefs; MSVC 18
  doesn't appear to define WIN32.
@oznogon oznogon force-pushed the refactor-guirotationdial-aimlock branch from af4b70a to 6e7acac Compare March 12, 2026 17:30
@daid
Copy link
Owner

daid commented Mar 19, 2026

It's a big of a visual shame to lose the rounded corners, this could potentially be fixed by rendering a (stretched) texture on the dial instead of a solid color.

@oznogon
Copy link
Contributor Author

oznogon commented Mar 20, 2026

Since this uses drawTriangleStrip I assume that'd require a drawTexturedTriangleStrip equivalent on the SP side to set the UVs, similar to drawTexturedQuad?

EDIT: Like daid/SeriousProton#306 ?

oznogon added 4 commits March 20, 2026 10:43
GuiRotationDial uses sprites for the handle and ring, which makes
resizing it inflexible and requires replacing sprites to theme it.

Use drawCircleOutline, triangle strips, and theme colors instead to
allow the ring and handle to be more easily customized.
Allow defining optional textures for the GuiRotationDial handle (front)
and ring (back).

- Rename dial_background.png to RotationDialBackground.png per other widget
  PNG naming conventions, and reshade to white to take theme colors better.
- Replace dial_button.png with new RotationDialHandle.png as a 9-segment
  stretched texture in white with rounded corners.
- Use drawTexturedTriangleStrip to texture the handle, falling back to
  colored drawTriangleStrip if no texture is defined in the theme.
- Update drawStretched call to apply a ring texture if present, falling
  back to colored drawCircleOutline.
@oznogon oznogon force-pushed the refactor-guirotationdial-aimlock branch from 5eb7b57 to 346831f Compare March 20, 2026 17:47
@oznogon
Copy link
Contributor Author

oznogon commented Mar 20, 2026

Refactored to use drawTexturedTriangleStrip, brought back textures for both the handle and ring, and made them optional to fall back on plain-color circle outline and triangle strip rendering if no textures are defined in the theme.

@oznogon oznogon marked this pull request as draft March 20, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants