Questions about overlay code

Hello friends,

I was thinking about implementing a way to show the Achievement badge when the user earns a cheevo (pretty much what @leiradel says here: https://github.com/libretro/RetroArch/issues/3946).

I wonder if it’s possible using overlays. But before diving into code, I would like to ask some questions for you guys who are more experienced with RetroArch internals.

  1. Where, in the current code, can I see some overlay related code to get inspired?

  2. Is it possible to show an image/overlay for an arbitrary amount of seconds? (my bet: yes, since we can enable/disable it on-the-fly via menu)

  3. Is it possible to add arbitrary text to the overlay? (my bet: not. It must be an image file)

Thanks in advance!

1 Like

I think most of the magic happens in tasks/task_overlay.c and input/input_overlay.c. I think one of the bigger limitations is that you have to load all of the overlay images into memory at load-time, so if you’re trying to hold more than, say, 2 dozen small images, you’re going to have long waits.

Yes, you should be able to enable/disable on the fly, but you can also include a blank overlay and use the overlay_next command to jump to/from it.

It’s not possible to do it through the overlay system, but it could be possible to put the overlay behind the normal onscreen display text, or just show an icon next to the text (a crown or a trophy or whatever).

1 Like

It’s feasible to start a task to show an award. This task can load the image from disk without blocking the game, and show it on top of the framebuffer.

My main issue is the size of the badges. They’re 64x64 pixels each, so when the game requests a framebuffer with a height of 200 pixels, and the frontend is either in windowed mode with 1x scale, or is fullscreen and gets an exact video mode from the driver, badges would take 1/3 of the screen vertically.

I’m not sure how to solve this. Having different badges for different resolutions doesn’t sound practical. Maybe we should have only one image to represent an award, like a trophy, in different resolutions. That image could always live in memory, and the badges would appear on the achievements list.

For the award text, we could also have bitmap fonts for different resolutions.