Clean up the OSD click callback code

This commit is contained in:
Henrik Rydgård committed 2026-02-09 13:08:44 +01:00
1 parent 4ccd41110b
commit a92ff89d5f
9 files changed
+43 -95

No files matched your search

+4 -7
View File
@@ -4,6 +4,7 @@
#include <string_view>
#include <vector>
#include <mutex>
#include <functional>
#include "Common/Common.h"
@@ -49,8 +50,6 @@ ENUM_CLASS_BITOPS(OSDMessageFlags);
// Data holder for on-screen messages.
class OnScreenDisplay {
public:
~OnScreenDisplay();
// If you specify 0.0f as duration, a duration will be chosen automatically depending on type.
void Show(OSDType type, std::string_view text, float duration_s = 0.0f, const char *id = nullptr) {
Show(type, text, "", duration_s, id);
@@ -90,8 +89,8 @@ public:
void ClearAchievementStuff();
// Can't add an infinite number of "Show" functions, so starting to offer post-modification.
void SetClickCallback(const char *id, void (*callback)(bool, void *), void *userdata);
void SetFlags(const char *id, OSDMessageFlags flag);
void SetFlags(std::string_view id, OSDMessageFlags flag);
void SetClickCallback(std::string_view id, std::function<void()> callback);
struct Entry {
OSDType type;
@@ -102,9 +101,7 @@ public:
std::string id;
OSDMessageFlags flags;
// We could use std::function, but prefer to do it the oldschool way.
void (*clickCallback)(bool, void *);
void *clickUserData;
std::function<void()> clickCallback;
int instanceID;
double startTime;