Skip to content

[WIP] Allow players to pick kart icon for profile (#1771) - #5907

Open
gui27souza wants to merge 13 commits into
supertuxkart:masterfrom
gui27souza:feat/1771-profile-icon
Open

gui27souza wants to merge 13 commits into
supertuxkart:masterfrom
gui27souza:feat/1771-profile-icon

Conversation

@gui27souza

@gui27souza gui27souza commented Oct 24, 2026 •

Copy link
Copy Markdown

Agreement

By creating a pull request in stk-code, you hereby agree to dual-license your contribution as
GNU General Public License version 3 or any later version and
Mozilla Public License version 2 or any later version.

This includes your previous contribution(s) under the same name of contributor.

You also confirm that this contribution is your own original work
and that it does not contain code generated by AI tools.

Keep the above statement in the pull request comment for agreement.

Summary

Work in progress for issue #1771. Players can now pick a native kart icon or enter a custom file path to set as their profile icon directly from the User Screen and Settings tab.

Current State & What works:

  • Native Kart Icons: Dynamic loading of available karts/icons, persistence to player profile, and immediate texture cache reload on UserScreen and TabbedUserScreen.
  • Custom Icon Upload (IconPathInputDialog):
    • Dedicated input dialog to type/paste a local file path.
    • Multi-step validation: file existence, allowed extensions (.png, .jpg, .jpeg), corrupted/unsupported file checks, and 1:1 aspect ratio tolerance (0.9 to 1.1).
    • Dynamic preview of the selected image before applying.
    • Profile persistence via PlayerProfile::setIconFromPath(...).
    • Desktop-only workflow (disabled on mobile with #ifdef MOBILE_STK).

image
image

Next Steps / WIP:

Following feedback from @SewerFox , modal dialogs have inherent engine limitations with dynamic ribbons (mouse clicks not triggering selection and keyboard focus quirks).

  • Convert IconSelectionDialog into a full Screen (IconSelectionScreen) to natively support mouse selection, arrow key navigation, and pagination arrows when many karts/addons are installed.

@SewerFox

Copy link
Copy Markdown
Contributor

Take a look here: https://github.com/supertuxkart/stk-code/blob/master/data%2Fgui%2Fdialogs%2Fandroid%2Fmultitouch_settings.stkgui

This uses a ribbon widget (to show the control methods for mobile)

@gui27souza

Copy link
Copy Markdown
Author

Take a look here: https://github.com/supertuxkart/stk-code/blob/master/data%2Fgui%2Fdialogs%2Fandroid%2Fmultitouch_settings.stkgui

This uses a ribbon widget (to show the control methods for mobile)

@SewerFox Thanks for the pointer! I took a look at multitouch_settings.stkgui, but it uses a static with pre-defined buttons declared directly in XML.

In our case, since the kart icons must be loaded dynamically (and we have lots of icons, requiring multiple rows/scrolling), I had to use <ribbon_grid> (DynamicRibbonWidget).

Exploring the codebase, I noticed that <ribbon_grid> is currently only used in full screens (like karts.stkgui or tracks.stkgui), and never inside a Dialog. That seems to be the root of the issue, in my view:

  1. In modal dialogs, mouse clicks on children of a ribbon widget seem to be ignored by the engine (event_handler.cpp filters out WTYPE_RIBBON parents in modals, so only keyboard Enter activates the item).

  2. The layout calculation in dialog causes the ribbon_grid to misalign or clip its upper border unless weird percentage paddings are hardcoded.

Do you guys know of any recommended way or existing pattern to dynamically display a list/grid of icons inside a dialog? I think it's better to stick to standard GUI practices rather than touching core engine behavior if possible. XD

@gui27souza

Copy link
Copy Markdown
Author

Just a quick update: I also enabled the "Choose Icon" option inside the settings tab (TabbedUserScreen / user_screen_tab.stkgui) to keep feature parity between both user management screens.
Since both inherit from BaseUserScreen, it reuses the same logic seamlessly.
Still keeping an eye out for any guidance on the dialog grid quirks whenever you have a moment. Thanks!

@gui27souza

Copy link
Copy Markdown
Author

Another update here: I manually aligned the ribbon_grid in the last commit
I still don't believe that's the right way, because the keyboard navigation and mouse click still doesn't work.
Still waiting for some help here, thanks in advance! XD

That's the current view

image

@gui27souza
gui27souza force-pushed the feat/1771-profile-icon branch from 1664c89 to 94a3824 Compare November 1, 2026 20:46
@gui27souza
gui27souza marked this pull request as ready for review November 11, 2026 22:55
@gui27souza

gui27souza commented Nov 11, 2026 •

Copy link
Copy Markdown
Author

Since the grid alignment is fixed, but still need some guidance on how to proceed, I'm sending this PR as ready for review, but also aware of what is still not ready on the Icon Selection Dialog:

  • Mouse selection: Hovering with the mouse highlights the item, but clicking doesn't trigger the selection action like pressing Enter on the keyboard does.
  • Arrow key navigation: Focus/arrow navigation across grid rows within the modal dialog doesn't work.

Even though, it's possible now to choose an icon directly from the user_screen:

  • Click Choose Icon
  • On the dialog, hover the one you want and click enter (a check badge will appear)
  • Click Apply
  • Icon changed!

@gui27souza gui27souza changed the title [WIP] Allow players to pick kart icon for profile (#1771) Allow players to pick kart icon for profile (#1771) Nov 11, 2026
@SewerFox

Copy link
Copy Markdown
Contributor

Hello Gui, I tested your code and the icon system works as promised, but about the UI, I think using the same DynamicRibbon style of the user icons in the user selection screen would be better than using a badge to indicate the selected icon (to follow the same pattern of all screens).
Btw, you should add a scroll system to the dialog because there have a big chance of overflow if the player have a big amount of karts installed.

@gui27souza

Copy link
Copy Markdown
Author

@SewerFox Hello! Thanks a lot for testing and for the feedback! XD

That makes total sense. Just to give a bit of context: I used the badge mainly as a workaround for the dialog quirks. Since mouse clicks weren't locking the focus/selection on ribbon items inside the modal, the badge was the only way I found to give visual feedback that an icon was picked.

Regarding the scroll system: when testing earlier, I tried <scrollable_ribbon>, but having all the kart icons in a single horizontal line didn't feel as pleasant for UX compared to seeing the grid of icons at once. If I'm not mistaken, <ribbon_grid> (DynamicRibbonWidget) already has pagination/scroll arrows built-in when there are many items, but the dialog event handling was getting in the way.

Because of that, I was considering turning IconSelectionDialog into a full Screen instead. That would likely solve all these GUI issues at once: mouse selection, keyboard/arrow navigation, and the native grid pagination would work out of the box (just like in the kart selection screen). What do you think about this approach?

Meanwhile, I'm almost done with the custom icon upload feature (which works independently of whether this is a Dialog or a Screen) and I plan to finish first. If handling the ribbon inside a modal proves too problematic, I can try converting it to a Screen. Sounds like a good plan?

@SewerFox

Copy link
Copy Markdown
Contributor

Well, taking in account that there is a real change of some player have gazillion of installed karts (that's usual), the screen may be the most suitable option imo

@gui27souza gui27souza changed the title Allow players to pick kart icon for profile (#1771) [WIP] Allow players to pick kart icon for profile (#1771) Nov 22, 2026
@gui27souza

Copy link
Copy Markdown
Author

Quick update

As planned, I've just pushed the custom icon upload implementation to this PR:

  • Added IconPathInputDialog with real-time validation (checks file existence, supported extensions .png, .jpg, .jpeg, image integrity via video driver, and 1:1 aspect ratio tolerance).
  • Added image preview widget before applying.
  • Handled profile persistence via PlayerProfile::setIconFromPath(...) with DRY refactoring.
  • Disabled the upload button on mobile builds (#ifdef MOBILE_STK) since file path input is a desktop-only workflow.

I also changed the PR back to [WIP] and updated the description. Now that the upload backend and UI are in place, my next step is converting the IconSelectionDialog into a full Screen to finally fix the grid navigation, mouse clicks, and scrolling. Thanks again for all the pointers!

@SewerFox

SewerFox commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor
image Worked very well :)

You should add something teaching the player how to find the localization of an image file (or maybe a calling for the system file selection screen)

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