otavepto / gbe_fork

Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
https://gitlab.com/Mr_Goldberg/goldberg_emulator
GNU Lesser General Public License v3.0
191 stars 55 forks source link

Improve achievement notification #138

Closed schmurger closed 2 months ago

schmurger commented 2 months ago

Add rounded corners to the notification Calculate achievement notification height based on the icon size Change default background notification color to match steam color scheme

otavepto commented 2 months ago

Thank you

schmurger commented 2 months ago

Thanks for merging this PR. I see you've added even more improvements, including text height calculation :) Also, thanks for fixing the bug for the incorrect placement of PopStyleVar.

otavepto commented 2 months ago

@schmurger Wanted to let you know I found a hacky way to dynamically set the notification height https://github.com/otavepto/gbe_fork/blob/21cce304e8eb77d5970d3197b0208cc50f6ff55b/overlay_experimental/steam_overlay.cpp#L837-L870 The trick to get the proper height is using ImGui::CalcTextSize() and passing the max allowed width as: total notification width - icon size - items spacing (because we draw an icon next to the the text) - window padding * 2 (padding left & right) This function conveniently works with multi-line strings, and it will now return back the required height.

Another thing related to ImGui in general, all ImGui::Pushxxx and ImGui::Popxxx must be balanced, I changed your code to pop the style outside the loop just like its equivalent push 👍

schmurger commented 2 months ago

That's a great way to size the notification correctly, including for chats as well. I didn't test that, I only worked with achievements. I'm quite new at graphics programming, it's interesting, lots of calculations so far :)