From ec32e87eb36f461c31f6cfde670074a87f58ba20 Mon Sep 17 00:00:00 2001 From: CallowBlack Date: Sun, 29 May 2022 15:29:42 +0300 Subject: [PATCH] little event improvement & add `OpenURL` utility function --- cheat-base/src/cheat-base/events/event.hpp | 11 +++++++++++ cheat-base/src/cheat-base/util.cpp | 6 ++++++ cheat-base/src/cheat-base/util.h | 1 + 3 files changed, 18 insertions(+) diff --git a/cheat-base/src/cheat-base/events/event.hpp b/cheat-base/src/cheat-base/events/event.hpp index b3e1483..96d6611 100644 --- a/cheat-base/src/cheat-base/events/event.hpp +++ b/cheat-base/src/cheat-base/events/event.hpp @@ -63,6 +63,12 @@ struct EventCore { using TMyHandlerPtr = typename TypeHelper::TEventHandlerPtr; + EventCore() {} + EventCore(const EventCore& other) : handlers(other.handlers) {} + EventCore(EventCore&& other) : handlers(std::move(handlers)) {} + EventCore& operator=(const EventCore& other) { handlers = other.handlers; return *this; } + EventCore& operator=(EventCore&& other) { handlers = std::move(other.handlers); return *this; } + std::list handlers; mutable std::shared_mutex coreMutex; }; @@ -126,6 +132,11 @@ class TEvent : public IEvent { } + TEvent(const TEvent& other) : m_core(other.m_core), m_handlerRunners(other.m_handlerRunners) + { + + } + virtual void operator()( TParams... params ) { TMyHandlerRunner newHandlerRunner( m_core ); diff --git a/cheat-base/src/cheat-base/util.cpp b/cheat-base/src/cheat-base/util.cpp index 8741730..1557180 100644 --- a/cheat-base/src/cheat-base/util.cpp +++ b/cheat-base/src/cheat-base/util.cpp @@ -3,6 +3,7 @@ #include "util.h" #include +#include #include #include #include @@ -270,4 +271,9 @@ namespace util return static_cast(timezoneInfo.Bias) * 60; } + + void OpenURL(const char* url) + { + ShellExecute(nullptr, nullptr, url, nullptr, nullptr, SW_SHOW); + } } \ No newline at end of file diff --git a/cheat-base/src/cheat-base/util.h b/cheat-base/src/cheat-base/util.h index 48c09d3..d3cf0eb 100644 --- a/cheat-base/src/cheat-base/util.h +++ b/cheat-base/src/cheat-base/util.h @@ -32,6 +32,7 @@ namespace util std::optional SelectDirectory(const char* title); std::optional GetOrSelectPath(CSimpleIni& ini, const char* section, const char* name, const char* friendName, const char* filter); + void OpenURL(const char* url); std::string GetLastErrorAsString(DWORD errorId = 0); int64_t GetCurrentTimeMillisec();